Function Reference


FileFlush

Flushes the file's buffer to disk.

FileFlush ( "filehandle" )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen.

Return Value

Success: Returns true if the buffer was flushed (or did not need to be flushed).
Failure: Returns false.

Remarks

A file is flushed when its handle is closed or when Windows internal buffer is full. This function forces an immediate flushing of the buffer.
This function can only be used with file handles returned from FileOpen().

Related

FileClose, FileOpen, FileWrite, FileWriteLine, FileSetPos

Example


Local Const $sFile = "test.txt"
Local $hFile = FileOpen($sFile, 1)

; Check if file opened for writing OK
If $hFile = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Write something to the file.
FileWriteLine($hFile, "Line1")

; Run notepad to show that the file is empty because it hasn't been flushed yet.
RunWait("notepad.exe " & $sFile)

; Flush the file to disk.
FileFlush($hFile)

; Run notepad again to show that the contents of the file are now flushed to disk.
RunWait("notepad.exe " & $sFile)

; Close the handle.
FileClose($hFile)

; Clean up the temporary file.
FileDelete($sFile)