When overridden in a derived class, sets the length of the current stream.
[Visual Basic] Public MustOverride Sub SetLength( _ ByVal value As Long _ ) [C#] public abstract void SetLength( long value ); [C++] public: virtual void SetLength( __int64 value ) = 0; [JScript] public abstract function SetLength( value : long );
- The desired length of the current stream in bytes.
|IOException||An I/O error occurs.|
|NotSupportedException||The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output.|
|ObjectDisposedException||Methods were called after the stream was closed.|
For an example of creating a file and writing text to a file, see Writing Text to a File. For an example of reading text from a file, see Reading Text from a File. For an example of reading from and writing to a binary file, see Reading and Writing to a Newly Created Data File.
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 length of the stream, the stream is expanded. If the stream is expanded, the contents of the stream between the old and the new length are not defined.
A stream must support both writing and seeking for SetLength to work.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard