Friday, October 28, 2011

Convert an Image to byte array in one line

Here's an easy way to convert any file on disk to a byte array
System.IO.File.ReadAllBytes(string filePath);
//The other way around:
System.IO.File.WriteAllBytes(string filePath, byte[] sourceBytes);