Navigation Bar

Tuesday, May 26, 2009

Convert File to Byte Array

System.IO.FileInfo fi = new System.IO.FileInfo(FileName);

if (fi.Exists)
{
FileInfo fInfo = new FileInfo(FileName);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(FileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
byte[] data = br.ReadBytes((int)numBytes);
// Show the number of bytes in the array.
//Label1.Text = Convert.ToString(data.Length);
br.Close();
fStream.Close();
}

No comments:

Post a Comment