DeleteDirectory2

Deletes a directory.


Syntax

FileSystem.DeleteDirectory2(Directory, UIOption, RecycleOption)

FileSystem.DeleteDirectory2(Directory, UIOption, RecycleOption, UICancelOption)


Parameters


Directory

String, input



Directory to be deleted.


UIOption

Enumeration, input



Whether to visually track the operation's progress. Default is OnlyErrorDialogs.


RecycleOption

Enumeration, input



Specifies whether the directory and it's contents should be deleted permanently or placed in the Recycle Bin. Default is DeletePermanently.


UICancelOption

Enumeration, input



Specifies what should be done if the user clicks Cancel during the operation. Default is ThrowException.


Remarks


UIOption



UIOption.AllDialogs

Show progress dialog box and any error dialog boxes.


UIOption.OnlyErrorDialogs

Only show error dialog boxes and hide progress dialog boxes. Default.


UICancelOption



UICancelOption.DoNothing

Do nothing when the user clicks Cancel.


UICancelOption.ThrowException

Throw an exception when the user clicks Cancel. Default.


RecycleOption



RecycleOption.DeletePermanently

Delete the directory permanently. Default.


RecycleOption.SendToRecycleBin

Send the directory to the Recycle Bin.


Examples

This example deletes the specified directory and all of its contents, asking the user to confirm the deletion, but does not send the contents to the Recycle Bin:


Sub Main()

FileSystem.DeleteDirectory2 "C:\Users\Public\My Directory\", UIOption.AllDialogs, RecycleOption.DeletePermanently, UICancelOption.ThrowException

End Sub


This example deletes the specified directory and all of its contents, sending them to the Recycle Bin, but does not show the progress of the operation:


Sub Main()

FileSystem.DeleteDirectory2 "C:\Users\Public\My Directory\", UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin, UICancelOption.ThrowException

End Sub