MemoryStream: ReadBlock

ReadBlock

Reads a specifiec number of bytes from the stream.



 Public Function ReadBlock(
	  ByRef Buffer ( ) As Byte,
	  ByVal Offset As Long,
	  ByVal Count As Long ) As Long

Parameters

Buffer
[ByRef] Byte. The destination to store the bytes being read from the stream.
Offset
[ByVal] Long. The startind index in Buffer to begin storing the bytes read from the stream.
Count
[ByVal] Long. The maximum number of bytes to be read from the stream.

Return Values

Long -  The total number of bytes read from the stream.

Remarks

If Offset plus Count exceeds the end of Buffer then an exception will be thrown. If the current position in the stream is closer to the end than Count bytes, then only the remaining bytes will be read.

The stream must be open to read from it, otherwise an exception will be thrown.

After reading from the stream, the current position will advance the number of byte as returend.

Exceptions

ExceptionCondition
ArgumentNullExceptionBuffer is uninitialized.
ArgumentExceptionOffset subtracted from the Buffer length is less than Count.
ArgumentOutOfRangeExceptionOffset or Count is negative.
ObjectDisposedExceptionThe current stream instance is closed.

See Also

Project CorLib Overview

Class MemoryStream Overview