This code will be show you how to convert an image to byte array using c#.net
We will use the MemoryStream class to write a image data to stream, then convert to byte array
public byte[] ConvertImageToByteArray(Image img)
{
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, img.RawFormat);
return ms.ToArray();
}
}
As you know, the MemoryStream class is very useful for writing data to stream