Functions.FFlush Method (IntPtr, Logic)
Flush to disk a file opened with a low-level file function.
XSharp.Core (in XSharp.Core.dll) Version: 2.16
Syntax Request Example
ptrHandle AS IntPtr,
lCommit AS LOGIC
) AS LOGIC
public static bool FFlush(
- Type: IntPtr
The handle of the open file you want to flush.
- Type: Logic
When you pass TRUE for this parameter then also all intermediate buffers are flushed.
FFlush() writes buffers to disk, thus releasing the memory used by those buffers.
If files are being shared in a multi-user or multi-tasking environment, FFlush() allows each user to see the latest contents of the file.
By flushing data from memory, FFlush() can also protect against possible data loss due to a system crash.
Calling the method with 2 parameters and a second parameter with the value TRUE will significantly slow down your apps!
The with 1 parameter works the same as calling FFlush() with a value of FALSE for the second parameter.
The low level File IO functions in the X# runtime are using .Net filestreams in the background. |
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles,
but unique identifiers that are used to find the underlying stream object in a collection of
streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not
created in the X# runtime.
If you want to access the underlying FileStream, then you should call the
This example uses FFlush() to flush data automatically after waiting for a key press:
1ptrHandle := FOpen2("docs.txt", ;
2 FO_READWRITE + FO_SHARED)
3IF ptrHandle != F_ERROR
4 FWrite(ptrHandle, Space(100))
5 nKey := Inkey(50)