StreamReader.Close StreamReader.Close StreamReader.Close StreamReader.Close Method

定義

關閉 StreamReader 物件和基礎資料流,並釋放任何與讀取器相關聯的系統資源。Closes the StreamReader object and the underlying stream, and releases any system resources associated with the reader.

public:
 override void Close();
public override void Close ();
override this.Close : unit -> unit
Public Overrides Sub Close ()

備註

這個方法會覆寫TextWriter.Close方法。This method overrides the TextWriter.Close method.

這個實作Close呼叫Dispose方法並傳遞true值。This implementation of Close calls the Dispose method passing a true value.

排清資料流不會清除其基礎的編碼器,除非您明確地呼叫CloseFlushing the stream will not flush its underlying encoder unless you explicitly call Close. 設定AutoFlushtrue表示資料會從排清緩衝區資料流,但並不會清除編碼器的狀態。Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. 這可讓編碼器,讓它可以正確編碼字元的下一個區塊保持其狀態 (部分的字元)。This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. 這個案例會影響 UTF8,UTF7,其中某些字元可以編碼的編碼器接收或多個相鄰的字元時,才。This scenario affects UTF8 and UTF7, where certain characters can be encoded only after the encoder receives the adjacent character or characters.

呼叫Close,任何讀取器上的作業可能會引發例外狀況。Following a call to Close, any operations on the reader might raise exceptions.

適用於

另請參閱