Constructors: NewMemoryStream

NewMemoryStream

Initializes a new instance of the MemoryStream class based on the specified region of a byte array, with the CanWrite property set as specified.



 Public Function NewMemoryStream(
	  ByRef Buffer ( ) As Byte,
	  Optional ByRef Index As Variant,
	  Optional ByRef Count As Variant,
	  Optional ByVal Writable As Boolean = True,
	  Optional ByVal Mode As BufferMode = ShareMode ) As MemoryStream

Parameters

Buffer
[ByRef] Byte. The array of bytes from which to create this stream.
Index
[ByRef] Optional. Variant. The index in Buffer at which the stream begins. The default is lower bound of Buffer.
Count
[ByRef] Optional. Variant. The length of the stream in bytes. The default is Buffer length.
Writable
[ByVal] Optional. Boolean. The setting of the CanWrite property, which determines whether the stream supports writing.  

Default: True

Mode
[ByVal] Optional. BufferMode. A BufferMode value specifying how Buffer is handled internally.  

Default: ShareMode

Return Values

MemoryStream -  The newly created MemoryStream containing the supplied byte buffer.

Remarks

The CanRead and CanSeek properties are both set to True. Capacity is set to Count.

The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see SetLength).

Exceptions

ExceptionCondition
ArgumentNullExceptionBuffer is uninitialized.
ArgumentOutOfRangeExceptionIndex or Count are negative.
ArgumentExceptionThe buffer length minus Index is less than Count.

See Also

Project CorLib Overview

Class Constructors Overview