I'm about to rip out what little hair I have left; I have a class that
uses a BinaryReader, and the data is getting munged. A subset of the
code follows; I've removed the parts that aren't relevant.
What's really strange is that it reads the file just fine until the
272nd call to the Read method of the class, at which point it begins
munging the data.
Any thoughts would be greatly appreciated; I've tried reading by byte,
as well as reading blocks, and it makes no difference.
-Kevin
public class HeaderStream
{
private const int c_BlockSize = 680;
private System.IO.BinaryReader str;
public HeaderStream(string path)
{
FileStream s = new FileStream(path,
FileMode.Open,
Read);
str = new BinaryReader(s);
}
public OWHeader Read()
{
byte[] buf = new byte[c_BlockSize];
int i;
i = str.Read(buf, 0, c_BlockSize);
if (i != c_BlockSize)
throw new EndOfStreamException(
String.Format(
"End of stream reached with bytes left to read"));
return new OWHeader(buf);
}
}