Is there any way to close a streamwriter without closing its basestreamapp
If you are using .NET Framework 4.5 or later, there is a StreamWriter overload using which you can ask the base stream to be left open when the writer is closed.code
In earlier versions of .NET Framework prior to 4.5, StreamWriter
assumes it owns the stream. Options:get
StreamWriter
; just flush it.Close
/Dispose
but proxies everything else alongThis is the overload methodit
public StreamWriter (System.IO.Stream stream, System.Text.Encoding encoding, int bufferSize, bool leaveOpen); io