Mono Class Library: System.IO.FileStream Overview | MembersSystem.IO.FileStream.Read Method |
Reads a block of bytes from the stream and returns the data in the specified buffer. [Edit]
|
- array
- A byte array. When this method returns, the bytes between offset and (offset + count - 1) in array are replaced by the bytes read from the current stream. [Edit]
- offset
- A int containing the byte offset in array at which to begin writing data read from the current stream. [Edit]
- count
- A int containing maximum number of bytes to read. [Edit]
A int containing the total number of bytes read into the buffer, or zero if the end of the stream is reached. [Edit]
Type Reason ArgumentNullException array is null. [Edit] ArgumentOutOfRangeException offset or count is negative. [Edit] NotSupportedException The current stream does not support reading. [Edit] System.IO.IOException An I/O error occurred. [Edit] ArgumentException offset + count is greater than the length of array. [Edit] ObjectDisposedException The current stream is closed. [Edit]
The FileStream.Read(Byte[], int, int) method returns zero only after reaching the end of the stream. Otherwise, FileStream.Read(Byte[], int, int) always reads at least one byte from the stream before returning. If no data is available from the stream, this method blocks until at least one byte of data can be returned.
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.
Note: Use the FileStream.CanRead property to determine whether the current instance supports reading. For additional information, see Stream.CanRead.Note: This method overrides Stream.Read(Byte[], int, int) .[Edit]
Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0