Type Reason System.IO.IOException An I/O error occurred. NotSupportedException The current stream does not support writing and seeking. ArgumentOutOfRangeException value is less than zero.
This method overrides Stream.SetLength(long).
If the given value is less than the current length of the stream, the stream is truncated. If the given 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 undefined.
A stream must support both writing and seeking for SetLength to work.
Use the FileStream.CanWrite property to determine whether the current instance supports writing, and the FileStream.CanSeek property to determine whether seeking is supported. For additional information, see Stream.CanWrite and Stream.CanSeek.
For a list of common file and directory operations, see Common I/O Tasks.