BUG: MoveFileEx Deletes the File Being Renamed

ID: Q193070

The information in this article applies to:

SYMPTOMS

If you call MoveFileEx with the MOVEFILE_REPLACE_EXISTING flag to rename a file to the same, current name or to a name that only differs in case, MoveFileEx might fail with error 2 (ERROR_FILE_NOT_FOUND) and delete the file.

This only happens when you get access to the file using a UNC path name or through a mapped drive.

RESOLUTION

Use MoveFileEx to rename the file to a different, temporary name and then rename the file back to the original name with the correct case.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

Additional query words:

Keywords          : kbAPI kbFileIO kbKernBase kbSDKPlatform 
Issue type        : kbbug
Solution Type     : kbfix

Last Reviewed: September 25, 1998