如何确保已物理写入到磁盘中的所有数据? [英] How to ensure all data has been physically written to disk?

查看:319
本文介绍了如何确保已物理写入到磁盘中的所有数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,.NET的FileStream的冲洗方法仅把当前缓冲区写入磁盘,但依赖于Windows的磁盘驱动器和硬盘的固件,这是不能保证数据实际物理写入磁盘。

I understand that .NET FileStream's Flush method only writes the current buffer to disk, but dependent on Windows' disk driver and the hard disk firmware this is no guarantee that the data is actually physically written to disk.

是否有.NET或Win32的方法,可以给我这个保证呢?所以,如果有功率损失十亿分之一秒后调用此方法回来,我还是可以肯定的是一切正常?

Is there a .NET or Win32 method that can give me this guarantee? So if there is power loss one nanosecond after the call to this method comes back, I can still be sure that everything is OK?

推荐答案

在Windows下,看的 FlushFileBuffers (Win32 API的)。

Under Windows, look at FlushFileBuffers (Win32 API).

这篇关于如何确保已物理写入到磁盘中的所有数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆