ImageEn, unit iexWindowsFunctions

WindowsRename


Declaration

function WindowsRename(Handle : HWnd; const sFilename, sNewName: String; bRenameOnCollision, bShowConfirmation : Boolean; bVerboseErrors : boolean = True; bCheckForOverwrite : Boolean = True): Boolean; overload;


Description

Uses PerformSHFileOperation to rename a file or a folder.

Parameter Description
Handle Owner Handle. Can specify 0
sFilename/ssFiles The file(s) to rename (only one can be specified
sNewName The new filename for the file (do not include path)
bRenameOnCollision Give the file being operated on a new name if a file with the target name already exists at the destination (pertains to FOF_RENAMEONCOLLISION
bShowConfirmation If not specified then will automatically respond with "Yes to All" for any dialog box that is displayed (undefines FOF_NOCONFIRMATION
bVerboseErrors Displays a dialog to the user if an error occurs (undefines FOF_NOERRORUI

Result is true unless the operation fails or is aborted.


Example

WindowsRename(Form1.Handle, 'C:\My Image.jpg', 'My New Name.jpg', True, True);