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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top