FIX: MoveFileEx Deletes the File Being Renamed

ID: Q193070


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), used with:
    • Microsoft Windows NT 4.0
    • Microsoft Windows 2000


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.

Additional query words:

Keywords : kbAPI kbFileIO kbKernBase kbNTOS400 kbWinOS2000 kbSDKPlatform kbDSupport kbGrpKernBase
Version : winnt:4.0
Platform : winnt
Issue type : kbbug


Last Reviewed: January 10, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.