I have written a little backup program. When a file is open it will not copy.
The CopyFileEx API Call Fails. I even used the COPY_FILE_OPEN_SOURCE_FOR_WRITE option.
If I open the file first using CreateFileA for GENERIC_READ
with Share Mode of:
FILE_SHARED_READ OR FILE_SHARED_WRITE,
and the CreationDisposition is: OPEN_EXISTING,
with attributes set to: FILE_ATTRIBUTE_NORMAL
Then the file opens successfully. Which I then close with CloseHandle.
But still when I try to use CopyFileEx it fails to copy the file.
What is even worse is that to old version of the file stored on the backup drive gets erased.