I’m trying to read/write the same image file’s stream. The image file read is working fine but When I writes the image file successfully and then open the image, It shows “It appears that we don’t support this file format.”
//reading jpeg image file
string fileContent = string.Empty;
using (FileStream fileStream = new FileStream("sparrow.jpeg", FileMode.Open, FileAccess.Read))
{
using (StreamReader reader = new StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}
//writing jpeg image file
byte[] imageBytes = Encoding.Unicode.GetBytes(fileContent);
System.IO.File.WriteAllBytes("sparrow2.jpeg", imageBytes);
7