FileSystemProxy.DeleteDirectory Method (String, UIOption, RecycleOption)
Deletes a directory.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public void DeleteDirectory( string directory, UIOption showUI, RecycleOption recycle )
Directory to be deleted.
Specifies whether to visually track the operation's progress. Default is UIOption.OnlyErrorDialogs.
Specifies whether or not the deleted file should be sent to the Recycle Bin. Default is RecycleOption.DeletePermanently.
The path is a zero-length string, is malformed, contains only white space, or contains invalid characters (including wildcard characters). The path is a device path (starts with \\.\).
directory is Nothing or an empty string.
The directory does not exist or is a file.
The directory is not empty, and onDirectoryNotEmpty is set to ThrowIfDirectoryNonEmpty.
The user does not have permission to delete the directory or subdirectory.
A file in the directory or subdirectory is in use.
The directory name contains a colon (:).
The path exceeds the system-defined maximum length.
The user does not have required permissions.
The user cancels the operation or the directory cannot be deleted.
The showUI and recycle parameters are not supported in applications that are not user interactive, such as Windows Services.
The example deletes the directory OldDirectory only if it is empty.
My.Computer.FileSystem.DeleteDirectory( "C:\OldDirectory", FileIO.DeleteDirectoryOption.ThrowIfDirectoryNonEmpty)
This example deletes the directory OldDirectory and all of its contents.
My.Computer.FileSystem.DeleteDirectory( "C:\OldDirectory", FileIO.DeleteDirectoryOption.DeleteAllContents)
This example deletes the directory OldDirectory and all of its contents, asking the user to confirm the deletion, but does not send the contents to the Recycle Bin.
My.Computer.FileSystem.DeleteDirectory( "C:\OldDirectory", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently, FileIO.UICancelOption.ThrowException)
This example deletes the directory OldDirectory and all of its contents, sending them to the Recycle Bin, but does not show the progress of the operation.
Available since 2.0