What's the difference between FileStream.Flush() and FileStream.Flush(True)?

前端 未结 3 633
时光说笑
时光说笑 2021-02-18 12:33

MSDN says that FileStream.Flush(True) \"also clears all intermediate file buffers.\".

What does \"all intermediate file buffers\" mean exactly?

3条回答
  •  孤城傲影
    2021-02-18 13:31

    It causes the file data that's buffered in the file system cache to be written to disk. That data is normally lazily written, based on the position of the disk write head. Having a gigabyte of cached data is technically possible so it can take quite a while. If this is important to you then consider the FileOptions.WriteThrough option instead. It disables write caching completely. This can be very expensive; you'll discover how slow hard disks really are.

提交回复
热议问题