Question:
How can I guarantee that information I have written to a binary
file is flushed from the disk cache and actually written to the
disk?
Answer:
The following example demonstrates flushing the disk cache of
given binary file, so that data is guaranteed to be written
to the disk.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
f : file;
i : integer;
begin
i := 10;
AssignFile(f, 'C:\DownLoad\Test.Bin');
ReWrite(f, 1);
BlockWrite(f, i, sizeof(i));
FlushFileBuffers(TFileRec(f).Handle);
CloseFile(f);
end;