BufferedStream.SetLength(Int64) 方法

定义

设置缓冲流的长度。Sets the length of the buffered stream.

public:
 override void SetLength(long value);
public override void SetLength (long value);
override this.SetLength : int64 -> unit
Public Overrides Sub SetLength (value As Long)

参数

value
Int64

一个整数,指示当前缓冲流的所需长度(以字节为单位)。An integer indicating the desired length of the current buffered stream in bytes.

异常

value 为负数。value is negative.

流未打开或为 nullThe stream is not open or is null.

该流不支持写入和查找。The stream does not support both writing and seeking.

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

注解

在设置基础数据源或存储库的长度之前,将刷新缓冲区。The buffer is flushed before setting the length of the underlying data source or repository. 如果指定的值小于缓冲流的当前长度,则将截断缓冲流。If the specified value is less than the current length of the buffered stream, the buffered stream is truncated. 如果指定的值大于缓冲流的当前长度,则将展开缓冲流。If the specified value is larger than the current length of the buffered stream, the buffered stream is expanded. 如果缓冲流已展开,则不会定义旧长度与新长度之间缓冲流的内容。If the buffered stream is expanded, the contents of the buffered stream between the old and the new lengths are not defined.

如果需要,SetLength 刷新任何缓冲的写入。SetLength flushes any buffered writes if necessary.

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

适用于

另请参阅