Convert Image into a binary File and Save in TXT File

Step 1. Add Given namespaces 

using System.IO;
using System.Net;

Step 2. Add a Upload File control and a button

Step 3. Write this code on button click event

protected void Button1_Click(object sender, EventArgs e)
{
    string str = FileUpload1.FileName.ToString();
    FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Images/" + str.ToString()));
    byte[] imgbyte =File.ReadAllBytes(Server.MapPath("~/Images/" + str.ToString()));
    File.WriteAllBytes(Server.MapPath("~/Images/image1.txt"), imgbyte);
}

For more download the zip code

Thanks
Ebook Download
View all
Learn
View all