How to convert byte array to image file?

  1. Create a MemoryStream passing the array in the constructor.
  2. Read the image from the stream using Image.FromStream.
  3. Call theImg.Save("theimage.jpg", ImageFormat.Jpeg).

Remember to reference System.Drawing.Imaging and use a using block for the stream.


Create a memory stream from the byte[] array in your database and then use Image.FromStream.

byte[] image = GetImageFromDatabase();
MemoryStream ms = new MemoryStream(image);
Image i = Image.FromStream(ms);