Stream.SetLength(Int64) Stream.SetLength(Int64) Stream.SetLength(Int64) Stream.SetLength(Int64) Method

Definition

When overridden in a derived class, sets the length of the current stream.

public:
 abstract void SetLength(long value);
public abstract void SetLength (long value);
abstract member SetLength : int64 -> unit
Public MustOverride Sub SetLength (value As Long)

Parameters

value
Int64 Int64 Int64 Int64

The desired length of the current stream in bytes.

Exceptions

The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output.

Remarks

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.

Use the CanWrite property to determine whether the current instance supports writing, and the CanSeek property to determine whether seeking is supported.

Applies to

See also