....
One, the FileExists() check is unnecessary, as DeleteFileW() will do the same check and set GetLastError() accordingly.
.....
Just for the record, several variations that I sent the end user apparently received no error message from DeleteFile() and DeleteFileUTF8() but a subsequent call to FileExists() revealed that the file was, in fact still present. And, on one occasion, I saw a log that indicated, perhaps, the file was deleted but DeleteFile() said it failed ! However, as I later found out, the user was using a disk encryption system and a portable application handler to run it, collectively, we think that was somehow related to the issue. An update to VeraCrypt seems to have helped.
I could not duplicate the end user's problem myself so was dependent on sending him/her a test binary. Fortunately, this was a very cooperative user. One other person did have what might have been a similar problem but with hind sight I don't think that is the case.
Early stages of this problem was complicated by the fact that Linux/Mac are quite happy to overwrite an existing file with RenameFileUTF8() but Windows is not. But I recently discovered that Linux is also upset about using RenameFileUTF8() on an existing file if that existing file is on an SMB share. And smb is, of course a Windows protocol ......
I am convinced that this is one very specific, isolated case. I have left the obsessively careful code in there for Windows in my app, it does no harm and may, perhaps do some good ?
Thanks for input folks !
Davo