You don't need to use Flush
on the StreamWriter
, as you are disposing it (by having it in a using
block). When it's disposed, it's automatically flushed and closed.
You don't need to use Flush
on the MemoryStream
, as it's not buffering anything that is written to any other source. There is simply nothing to flush anywhere.
The Flush
method is only present in the MemoryStream
object because it inherits from the Stream
class. You can see in the source code for the MemoryStream
class that the flush
method actually does nothing.