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

定义

当在派生类中重写时,设置当前流的长度。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)

参数

value
Int64 Int64 Int64 Int64

所需的当前流的长度(以字节表示)。The desired length of the current stream in bytes.

异常

出现 I/O 错误。An I/O error occurs.

流不支持写入和查找,例如在流通过管道或控制台输出构造的情况下即为如此。The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output.

在流关闭后调用方法。Methods were called after the stream was closed.

注解

如果指定的值小于当前流的长度,则流被截断。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.

流必须支持写入和查找有关SetLength工作。A stream must support both writing and seeking for SetLength to work.

使用CanWrite属性来确定当前实例是否支持写入,和CanSeek属性来确定是否支持查找。Use the CanWrite property to determine whether the current instance supports writing, and the CanSeek property to determine whether seeking is supported.

适用于

另请参阅