MemoryStream: WriteBlock

WriteBlock

Writes an array of bytes to the underlying stream.



 Public Sub WriteBlock(
	  ByRef Buffer ( ) As Byte,
	  ByVal Offset As Long,
	  ByVal Count As Long )

Parameters

Buffer
[ByRef] Byte. The bytes to be written to the stream.
Offset
[ByVal] Long. The starting index in Buffer to begin writing from.
Count
[ByVal] Long. The maximum number of bytes to be written to the stream.

Remarks

The Offset parameter gives the offset of the first byte in Buffer to write from, and the Count parameter gives the number of bytes to write. If the write operation is successful, the current position within the stream is advanced by the number of bytes written. If an exception occurs, the current position within the stream is unchanged.

Except for a MemoryStream constructed with a Byte() parameter, write operations at the end of a MemoryStream expand the MemoryStream.

Exceptions

ExceptionCondition
ArgumentNullExceptionBuffer is uninitialized.
NotSupportedException The stream does not support writing. For additional information see CanWriter.
-or-
The current position is closer than Count bytes to the end of the stream, and the capacity cannot be modified.
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