Tuesday, June 30, 2009

Get Bytes [] from the File

public byte[] GetBytesFromFile(string fullFilePath)
{
// this method is limited to 2^32 byte files (4.2 GB)

FileStream fs = File.OpenRead(fullFilePath);
try
{
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
fs.Close();
return bytes;
}
finally
{
fs.Close();
}

}

No comments:

Post a Comment

 
Locations of visitors to this page