Why FileStream.Length is long type, but FileStream.Read argument - offset has a shorter length?

The offset is the index into the byte array where the data is placed. You can't allocate an array that is larger than 2 GB, so there is no need for a bigger number for the offset.


The offset parameter tells where to start writing data in your array, the array parameter. It does not point out an offset in the file data.

The offset parameter gives the offset of the byte in array (the buffer index) at which to begin reading, and the count parameter gives the maximum number of bytes to be read from this stream. The returned value is the actual number of bytes read, or zero if the end of the stream is reached. If the read operation is successful, the current position of the stream is advanced by the number of bytes read. If an exception occurs, the current position of the stream is unchanged.

Source: FileStream.Read

Tags:

C#