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.
In earlier versions of .NET Framework prior to 4.5, StreamWriter assumes it owns the stream. Options:
- Don’t dispose the
StreamWriter; just flush it. - Create a stream wrapper which ignores calls to
Close/Disposebut proxies everything else along. I have an implementation of that in MiscUtil, if you want to grab it from there.