Reputation:
I am not sure if a buffer is also used when reading from a file, or is it only used when writing to a file.
Upvotes: 2
Views: 2662
Reputation: 7773
Here's what the documentation has to say to Stream.Flush():
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
I guess it's safe to say that flushing is not required when reading.
Upvotes: 1
Reputation: 9772
Do I need to flush a FileStream() when reading?
No. Flush() writes remaining Bytes in the write-buffer.
is a buffer is also used when reading from a file?
Yes there is a buffer for performance reasons, but there is no way to flush this buffer other than simply reading bytes form the stream until EOF is encountered.
Upvotes: 4