Sets the length of the current stream to the specified value.
[Visual Basic] Overrides Public Sub SetLength( _ ByVal value As Long _ ) [C#] public override void SetLength( long value ); [C++] public: override void SetLength( __int64 value ); [JScript] public override function SetLength( value : long );
Exception Type | Condition |
---|---|
ArgumentException | value is negative or is greater than Int32.MaxValue minus the origin. |
NotSupportedException | The current stream is not resizable and value is larger than the current capacity. |
IOException | The current stream does not support writing. |
If the specified value is less than the current length of the stream, the stream is truncated. If the specified value is larger than the current capacity and the stream is resizable, then the capacity is increased; otherwise a NotSupportedException is thrown. If the length is increased, the contents of the stream between the old and the new length are undefined. A stream must support both writing and seeking for this method to be operational.
MemoryStream Class | MemoryStream Members | System.IO Namespace