DirectoryInfo.Delete Method (Boolean)
Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.
Assembly: mscorlib (in mscorlib.dll)
The directory contains a read-only file.
The directory described by this DirectoryInfo object does not exist or could not be found.
The directory is read-only.
The directory contains one or more files or subdirectories and recursive is false.
The directory is the application's current working directory.
There is an open handle on the directory or on one of its files, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
The caller does not have the required permission.
The following example demonstrates deleting a directory. Because the directory is removed, first comment out the Delete line to test that the directory exists. Then uncomment the same line of code to test that the directory was removed successfully.
Write flag required for write permission to the DirectoryInfo and subdirectories to be deleted.
Available since 10
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0