LATEST UPDATES
ShareHolder Finder v0.9.1 is now released!!! Check Product Page for more details.
✉ info@automationdevelopers.com

ITS ALL ABOUT AUTOMATION

Sunday, 9 October 2016

AutoIt - How to Delete a Folder


Author Post Date Sunday, 9 October 2016
DirRemove function is used to delete a folder/ directory.

By default, the function deletes a folder only if it is empty (recurse flag - $DIR_DEFAULT (0)). Setting the recurse flag to $DIR_REMOVE (1) will remove files and sub directories. Also it will delete empty directories. 

DirRemove function returns 1 for success and 0 if there is an error deleting the directory. If the directory does not exist, the function returns 0.

Example:


#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

;Delete the directory recursively.
$bStatus = DirRemove("C:\automationdevelopers", $DIR_REMOVE)

;Display status message.
If $bStatus Then
    MsgBox($MB_ICONINFORMATION, "Status", "Directory deleted successfully.")
Else
    MsgBox($MB_ICONERROR, "Status", "Error deleting the directory.")
EndIf

Related Posts





Interesting? Share and Let Others Know.

Post a Comment