MemoryStream: SetLength |
Sets the current length of the stream.
Public Sub SetLength( ByVal Value As Currency )
The shortening the length of the stream will truncate the excess data. If increasing the length, then the new exposed data will be set to zero.
If a user-supplied byte array is being used, this function has limited capabilites. The size of the stream can be changed to withing the origin size of the user-supplied byte array. If a length greater than the original array size is set, then an exception is thrown.
Exception | Condition |
---|---|
NotSupportedException |
The current stream is not resizable and Value is larger than the current capacity. -or- The current stream does not support writing. |
ArgumentOutOfRangeException | value is negative or is greater than the maximum length of the MemoryStream, where the maximum length is( MaxValue - origin), and origin is the index into the underlying buffer at which the stream starts. |