Skip to content

Instantly share code, notes, and snippets.

@ayende
Created July 4, 2013 20:35
Show Gist options
  • Select an option

  • Save ayende/5930081 to your computer and use it in GitHub Desktop.

Select an option

Save ayende/5930081 to your computer and use it in GitHub Desktop.
public class ProperlyFlushFileStream : FileStream
{
[DllImport("kernel32.dll")]
static extern bool FlushFileBuffers(IntPtr hFile);
public void FSync()
{
base.Flush(false);
if(!FlushFileBuffers(SafeFileHandle))
throw new Win32Exception();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment