I am using Delphi 2010 and looking for a way to use CreateFile Windows API function to append data rather than overwriting it in the specified file?
I am not looking for an optional way to do it such as Append() or Rewrite() or similar. I am looking specifically to do this by use of CreateFile Windows API function.
I tried using:
// this will open existing file but will **overwrite** data in the file.
fHandle:= CreateFile(PChar(FName), GENERIC_READ or GENERIC_WRITE, 0,
nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// this will recreate file each time therefore deleting its original content
fHandle:= CreateFile(PChar(FName), GENERIC_READ or GENERIC_WRITE, 0,
nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
Much appreciated,