I have two files: A and B. I need to replace B with A, while B is opened in another program.
The following approach:
MoveFile to rename B to C, then rename A to B, then delete C
works fine. However I need an atomic way to do that, because if one rename fails the data will be left in inconsistent state.
I tried MoveFileEx with MOVEFILE_REPLACE_EXISTING flag, but it doesn't work when file B is opened by another program. Same for ReplaceFile function. Any other ideas? Thank you