FIX: MoveFileEx Deletes the File Being Renamed (193070)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000

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.

Modification Type:MajorLast Reviewed:4/9/2004
Keywords:kbAPI kbbug kbFileIO kbfix kbKernBase KB193070