StreamWriter.Dispose(Boolean) 方法


使任何緩衝資料都寫入基礎資料流,釋放 StreamWriter 所使用的非受控資源,然後選擇性地釋放受控資源。Causes any buffered data to be written to the underlying stream, releases the unmanaged resources used by the StreamWriter, and optionally the managed resources.

 override void Dispose(bool disposing);
protected override void Dispose (bool disposing);
override this.Dispose : bool -> unit
Protected Overrides Sub Dispose (disposing As Boolean)



true 表示釋放 Managed 和 Unmanaged 資源,false 則表示只釋放 Unmanaged 資源。true to release both managed and unmanaged resources; false to release only unmanaged resources.


目前的編碼不支援顯示 Unicode Surrogate 字組的其中一半。The current encoding does not support displaying half of a Unicode surrogate pair.


disposing 參數為 true 時,這個方法會釋放 StreamWriter 參考的任何 Managed 物件所掌握的資源。When the disposing parameter is true, this method releases all resources held by any managed objects that this StreamWriter references. 這個方法會叫用每個參考物件的 Dispose 方法。This method invokes the Dispose method of each referenced object.


Dispose 可以被其他物件呼叫多次。 Dispose can be called multiple times by other objects. 覆寫時 Dispose ,請小心不要參考先前在先前的呼叫中處置的物件 DisposeWhen overriding Dispose, be careful not to reference objects that have been previously disposed in an earlier call to Dispose.

這個方法會呼叫基類的 dispose 方法 Dispose(Boolean)This method calls the dispose method of the base class, Dispose(Boolean).