Knowledge Base

FIX: MoveFileEx Deletes the File Being Renamed

Article ID: 193070

Article Last Modified on 11/21/2006


APPLIES TO


This article was previously published under Q193070

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

The problem has been fixed in Windows 2000.

Keywords: kbapi kbbug kbfileio kbfix kbkernbase KB193070