Hi All,
What is the proper way to read a binary file into a byte[]?
I am using BinaryReader to read from a Stream and call the ReadByte method
of the BinaryReader object.
The method I'm using leads to the second question. I got the "Conversion
buffer overflow" error when I run the following code:
Stream s = openFileDialog1.OpenFile();
System.IO.BinaryReader br = new BinaryReader(s);
byte[] ba = new byte[s.Length]; // s.Length ~= 20000
while (br.PeekChar() > -1) {
ba[s.Position] = br.ReadByte(); // <- s.Position ~= 400 when error
occurred
}
Thanks in advance