什么是FileStream.Flush()和FileStream.Flush(真)之间的区别是什么?区别、FileStream、Flush

2023-09-03 02:21:30 作者:过去不重要

MSDN 说,FileStream.Flush(True) 还会清除所有中间文件的缓冲区。

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

什么是所有中间文件缓冲区的意思是什么呢?

What does "all intermediate file buffers" mean exactly?

推荐答案

这导致多数民众赞成在缓存文件系统缓存中的文件数据写入到磁盘中。该数据被正常懒惰地写入,基于盘写头的位置。其缓存数据的技嘉在技术上是可能的,因此可能需要相当长的时间。如果这是重要的是你再考虑 FileOptions.WriteThrough 选项。它完全禁用写缓存。这可以是非常昂贵的;你会发现硬盘到底有多慢的。

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.