Function Reference


DirRemove

Deletes a directory/folder.

DirRemove ( "path" [, recurse] )

Parameters

path Path of the directory to remove.
recurse [optional] Use this flag to specify if you want to delete sub-directories too.
  0 = (default) do not remove files and sub-directories
  1 = remove files and subdirectories (like the DOS DelTree command)

Return Value

Success: Returns 1.
Failure: Returns 0 if there is an error removing the directory (or if directory does not exist).

Remarks

Some dir attributes can make the removal impossible.

Related

DirCreate, DirCopy, DirMove, FileDelete, FileRecycle

Example


; Delete C:\Test1 and all subdirs and files
Local $sFldr1 = "C:\Test1\"
Local $sFldr2 = "C:\Test1\Folder1\"
Local $sFldr3 = "C:\Test1\Folder1\Folder2\"
If DirGetSize($sFldr1) = -1 Then
    DirCreate($sFldr3)
    Local $explorer = RunWait("explorer /root, C:\Test1\Folder1")
    Local $handle = WinGetHandle($explorer)
    MsgBox(262144, "Message", "Explorer is opened with Folder2 displayed.")
    DirRemove($sFldr3, 1)
    MsgBox(262144, "Message", "The sub folder: Folder2 has been deleted.")
    WinClose($handle)
    DirRemove($sFldr1, 1) ;clean up test folders
Else
    MsgBox(48, $sFldr1, "Directory already exists!")
EndIf