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.

適用於

另請參閱