Microsoft KB Archive/193070

{|
 * width="100%"|

FIX: MoveFileEx Deletes the File Being Renamed

 * }

Q193070

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows NT 4.0
 * the operating system: 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 kbOSWinNT400 kbOSWin2000 kbSDKPlatform kbDSupport kbGrpDSKernBase

Issue type : kbbug

Technology : kbAudDeveloper kbWin32sSearch kbWin32API