4

We have an application that makes a backup of a configuration file by copying it to a sub-folder (see log file entry below) using the following command:-

BOOL b = MoveFileEx(ExistingFileSpec, NewFileSpec, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED);

This appears to work as expected on most systems but on two we get the following warning in our log file:-

11 Jun 2018 10:58:05.437 W. COMMON WARNING MoveFile failed on C:\Program Files\Configuration\Stores.xml to C:\Program Files\Configuration\Backup\Stores.xml LastError=183

Lasterror =183 means "ERROR_ALREADY_EXISTS"

This is odd since MOVEFILE_REPLACE_EXISTING is specifically meant to enable this command to work when the target file exists.

This is happening on Win7 x86 machines.

In a previous version of the code MoveFile was used but with a DeleteFile call immediately prior to ensure the target file did not exist. When the code was rolled back to this version it works.

Any suggestions?

L_J
  • 2,351
  • 10
  • 23
  • 28
MPS
  • 41
  • 4
  • 3
    Apparently it was unable to replace the existing file for otherwise obscure reasons. The top of the hit parade of wonky file system problems is firmly held by anti-malware. They do treat XML files like dirt due to the DTD injection vulnerability. – Hans Passant Jul 16 '18 at 21:59
  • Apologies I thought I had responded, myst have been distracted before adding comment. I have confirmed that one site is running Symantec but the other is not. The issue is not consistent at first site - some machines experience the problem, others do not. At the second site we have setup a test having changed to use ReplaceFile instead of MoveFile. – MPS Jul 19 '18 at 10:33

0 Answers0