DeleteDirectory
DeleteDirectory
Deletes a directory.
Syntax
FileSystem.DeleteDirectory(Directory, DeleteDirectoryOption)
Parameters
Directory  | 
String, input  | 
|
Directory to be deleted.  | 
||
DeleteDirectoryOption  | 
Enumeration, input  | 
|
Specifies what should be done when a directory that is to be deleted contains files or directories. Default is DeleteAllContents.  | 
Remarks
DeleteDirectoryOption  | 
||
DeleteDirectoryOption.DeleteAllContents  | 
Delete the contents of the directory along with the directory. Default.  | 
|
DeleteDirectoryOption.ThrowIfDirectoryNonEmpty  | 
Throw an IOException if the directory is not empty. The Data property of the exception lists the file(s) that could not be deleted.  | 
Examples
This example deletes the specified directory only if it is empty:
Sub Main()
FileSystem.DeleteDirectory "C:\Users\Public\My Directory\", DeleteDirectoryOption.ThrowIfDirectoryNonEmpty
End Sub
This example deletes the specified directory and all of its contents:
Sub Main()
FileSystem.DeleteDirectory "C:\Users\Public\My Directory\", DeleteDirectoryOption.DeleteAllContents
End Sub