Assume the following code:
Stream file = files[0].InputStream; var FileLen = files[0].ContentLength; var b = new BinaryReader(file); var bytes = b.ReadBytes(FileLen);
If I upload a CSV file that is 10 records (257 bytes), BinaryReader fills the byte array with "0".
I also wrote a loop to go through the ReadByte method for BinaryReader, and in the first iteration of the loop, I got the following exception:
Unable to read beyond end of stream
When I expand the CSV file to 200 hundred records, everything works fine.
The question is why this happens on small files, and is there a workaround that allows binary reading of smaller files.
source share