Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The WriteFile function in Windows operating system always overwrites the existing content when writing to a file because it is designed to write at a specific position in the file, which is specified by the file pointer. When a write operation is performed, the file pointer is moved to the next available position in the file, and the data is written at that location, replacing any content that may exist at that position.

If you want to append data to the end of an existing file, you can move the file pointer to the end of the file using the SetFilePointer function and then use the WriteFile function to write the data at the new position. Alternatively, you can use a file operation that is specifically designed for appending data to the end of a file, such as the FILEAPPENDDATA flag in the CreateFile function, or the AppendFile function.