How can I convert any file into byte array?
It is very easy to save your bytes to File, look at the example below, copy and paste it into your program:
public byte[] FileToArray(string sFilePath)
{
System.IO.FileStream fs = new System.IO.FileStream(sFilePath,
System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
br.Close();
fs.Close();
return bytes;
}
some time we require to convert file into byte to save into database or send to other system using remoting.
We can use that function to convert file into byte array.


