Share via


SetLength Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Sets the length of this stream to the given value.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

Syntax

'Declaration
Public Overrides Sub SetLength ( _
    value As Long _
)
public override void SetLength(
    long value
)
public:
virtual void SetLength(
    long long value
) override
abstract SetLength : 
        value:int64 -> unit 
override SetLength : 
        value:int64 -> unit 
public override function SetLength(
    value : long
)

Parameters

Remarks

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.

Note

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

.NET Framework Security

See Also

Reference

FileStream Class

System.IO Namespace