Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MoveFileEx Deletes the File Being Renamed

Status
Not open for further replies.

EzehM

Programmer
Joined
Feb 27, 2003
Messages
86
Location
GB
According to Microsoft Knowledge Base Article - 193070

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.

Does this mean that I can not rename a file C:\b\abc.ACK.tmp to C:\b\abc.ACK ? using MoveFileEx with the MOVEFILE_REPLACE_EXISTING on Windows NT?

Thanks
Milton


 
"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 means: renaming abc.ack.tmp to (for example) ABC.ACK.tmp (same name), and does not mean renaming it to abc.ack (different name).

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

This usually means accessing the file through a network (UNC name has the form \\server\share\...., a mapped drive has the form x:\...., where x: usually (but not always) is on a remote computer). Normally the C:\ drive is a local drive.

So I expect no trouble for you with this.



Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top