Reading a file into a Byte[] in .NET 1.1

FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
long numBytes = new FileInfo(filePath).Length;
byte[] buff = br.ReadBytes((int)numBytes);
br.Close();
fs.Close();

Don’t forget to put the code in a try/catch/finally block. In finally block, call the Close() methods.

continue reading…