Redigera

Dela via


RandomAccess.FlushToDisk(SafeFileHandle) Method

Definition

Flushes the operating system buffers for the given file to disk.

public:
 static void FlushToDisk(Microsoft::Win32::SafeHandles::SafeFileHandle ^ handle);
public static void FlushToDisk (Microsoft.Win32.SafeHandles.SafeFileHandle handle);
static member FlushToDisk : Microsoft.Win32.SafeHandles.SafeFileHandle -> unit
Public Shared Sub FlushToDisk (handle As SafeFileHandle)

Parameters

handle
SafeFileHandle

The file handle.

Exceptions

handle is null.

handle is invalid.

The file is closed.

An I/O error occurred.

Remarks

This method calls platform-dependent APIs such as FlushFileBuffers() on Windows and fsync() on Unix.

Flushing the buffers causes data to be written to disk, which is a relatively expensive operation. It is recommended that you perform multiple writes to the file and then call this method either when you are done writing to the file or periodically if you expect to continue writing to the file over a long period of time.

Applies to