I have an application where I am trying to implement a "safe file overwrite" by:
- Creating a file (
A
) - Filling
A
with data - Copying
A
to its final destination (B
) viaSHFileOperation
- Deleting
A
usingDeleteFile
However in step 4 DeleteFile
always returns ERROR_SHARING_VIOLATION. The entire process takes milliseconds, so I can't imagine who else would be interfering with my file. A couple questions:
- Is there a better Win32 (C/C++) technique for performing the above?
- How can I get more information about the "other process" that's keeping me from deleting file
A
? - How do I gently (wink wink nudge nudge) force Windows to delete my temporary file?
Any other suggestions are welcome