Mono Class Library: System.IO.Stream Overview | Members

System.IO.Stream.Read Method

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

public abstract int Read (byte[] buffer, int offset, int count)

Parameters

buffer
A byte array. When this method returns, the elements between offset and (offset + count - 1) are replaced by the bytes read from the current source.
offset
A int that specifies the zero based byte offset in buffer at which to begin storing the data read from the current stream.
count
A int that specifies the maximum number of bytes to be read from the current stream.

Returns

A int that specifies the total number of bytes read into the buffer, or zero if the end of the stream has been reached before any data can be read.

Exceptions

TypeReason
ArgumentException(offset + count - 1) is greater than the length of buffer.
ArgumentNullExceptionbuffer is null.
ArgumentOutOfRangeExceptionoffset or count is less than zero.
System.IO.IOException An I/O error occurred.
NotSupportedExceptionThe current stream does not support reading.
ObjectDisposedExceptionThe stream is closed.

Remarks

Note: Use the Stream.CanRead property to determine whether the current instance supports reading.

Operation
As described above.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0