FlushFileBuffers, is really needed?

  • Thread starter Thread starter nulll
  • Start date Start date
N

nulll

Is needed call WinAPI FlushFileBuffers (by PInvoke) to ensure that data is
send to hard disk, or call System.IO.FileStream.Flush is sufficient?


Regards...
 
The System.IO.FileStream.Flush calls Kernel32's WriteFile internally (rather
than calling FlushFileBuffers) in synchronous mode. However, WriteFile does
some buffering internally and since the FileStream class does not use
FILE_FLAG_NO_BUFFERING, I guess if you really,really wanted to be sure that
the data is written to harddisk, you could call FlushFileBuffers. But I'm
curious as to why this is such a huge issue

Sriram Krishnan

http://www.dotnetjunkies.com/weblog/sriram
 
Back
Top