Im getting error Unable to read beyond the end of the stream why?

前端 未结 3 1884
再見小時候
再見小時候 2021-01-18 14:13

The testing.res file is 240MB size. I want to read it. But im getting the error on this line:

int v = br.ReadInt32();

EndOfStreamException

3条回答
  •  深忆病人
    2021-01-18 14:33

    The binary reader is not pointing to the start of the stream.

    Use this code before reading the integer value:

    br.BaseStream.Seek(0, SeekOrigin.Begin);
    

提交回复
热议问题