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
#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
- AutoIt - How to Create a Folder
- AutoIt - How to Copy a Folder
- AutoIt - How to Move a Folder
- AutoIt - How to Rename a Folder
Interesting? Share and Let Others Know.
Post a Comment