简体   繁体   中英

Windows Explorer renames files when copying and an existing file is found

Windows Explorer renames files when copying and an existing file is found - do we have access to that facility from Delphi code?

It would be fairly straight forward to write the code to rename the destination filename when using TFile.Copy() , but it would be better to use the existing code if available.

IFileOperation is the API to the shell's file copy functionality. Use it to replicate the shell's behaviour. In your case you will need to use SetOperationFlags to specify the FOF_RENAMEONCOLLISION flag:

Give the item being operated on a new name in a move, copy, or rename operation if an item with the target name already exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM