FileStream.Read() is defined as:
public override int Read(
byte[] array,
int offset,
int count
)
How can I read some bytes from an offset bigger than int.MaxValue?
Let’s say I have a very big file and I want to read 100MB starting from position 3147483648.
How can I do that?
The
offsethere is the offset in the array at which to start writing. In your case, just set:and then use
Read(). Theoffsetis most commonly used when you know you need to read [n] bytes:this will read exactly 20 bytes into
buffer(or throw an exception). Note thatRead()is not guaranteed to read all the required data in one go, hence a loop incrementing an offset is usually required.