Search code examples
c#.netfilestreamflush

Do I need to Flush() a FileStream when reading?


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.


Solution

  • 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.