Flush disk write cache

后端 未结 6 1208
天涯浪人
天涯浪人 2020-12-17 02:18

When the policy for a disk in Windows XP and Vista is set to enable write caching on the hard disk, is there a way to flush a file that has just been written, and ensure tha

6条回答
  •  忘掉有多难
    2020-12-17 02:49

    You haven't specified the development environment, so:

    .Net

    IO streams have a .Flush method that does what you want.

    Win32 API

    There is the FlushFileBuffers call, which takes a file handle as argument.

    EDIT (based on a comment from the OA): FlushFileBuffers does not need administrative privileges; it does only if the handle passed to it is the handle for a volume, not for a single file.

提交回复
热议问题