ImageEn, unit iexWindowsFunctions

WindowsErase


Declaration

function WindowsErase(Handle : HWnd; const sFilename: String; bSendToRecycleBin, bShowConfirmation, bShowProgress: Boolean; bVerboseErrors : boolean = True): Boolean;
function WindowsErase(Handle : HWnd; ssFiles : TStrings; bSendToRecycleBin, bShowConfirmation, bShowProgress: Boolean; bVerboseErrors : boolean = True): Boolean; overload;


Description

Uses PerformSHFileOperation to delete files from a folder.
Parameter Description
Handle Owner Handle. Can specify 0
sFilename/ssFiles The file(s) to delete. If using sFromFilename the multiple files can be delimited using #0
bSendToRecycleBin Moves the file to the Recycle Bin rather than permanently deleting it (pertains to FOF_ALLOWUNDO
bShowConfirmation If not specified then will automatically respond with "Yes to All" for any dialog box that is displayed (undefines FOF_NOCONFIRMATION
bShowProgress Displays a progress dialog box (undefines FOF_SILENT
bVerboseErrors Displays a dialog to the user if an error occurs (undefines FOF_NOERRORUI

Result is true unless the operation fails or is aborted.

Note: Both files and folders can be specified.


Example

WindowsErase(Form1.Handle, 'C:\My Image.jpg', True, True, True);

// Delete the folder C:\Images and all files that it contains
WindowsMove(Form1.Handle, 'C:\Images', True, True, True);