[Mono-devel-list] Flushing a FileStream to disk

Rodrigo B. de Oliveira rbo at acm.org
Fri Nov 5 09:01:17 EST 2004


This was contributed to Bamboo.Prevalence by Rafael Teixera:

namespace System.IO
{
 using System.Runtime.CompilerServices;

 internal enum MonoIOError: int { ERROR_SUCCESS = 0, ERROR_ERROR = -1 };

 internal sealed class MonoIO
 {
  [MethodImplAttribute (MethodImplOptions.InternalCall)]
  public static extern bool Flush(IntPtr handle, out MonoIOError error);
 }
}

I'm not really sure how the InternalCall binding works but it seems to do
the job well.

cheers,
Rodrigo

----- Original Message ----- 
From: "Jeroen Frijters" <jeroen at sumatra.nl>
To: <mono-devel-list at lists.ximian.com>
Sent: Friday, November 05, 2004 8:27 AM
Subject: [Mono-devel-list] Flushing a FileStream to disk


Hi,

In IKVM I need a way to flush a FileStream to disk (not just flushing
the managed buffer to the OS, which is what FileStream.Flush does).

On Windows I use:

void FlushToDisk(FileStream fs)
{
  if(!FlushFileBuffers(fs.Handle))
    throw new IOException();
}

[DllImport("kernel32")]
static extern bool FlushFileBuffers(IntPtr handle);

What would be the equivalent on Mono on Linux?

Thanks.

Regards,
Jeroen
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list