DirectoryInfo.Delete Method ()

 

Deletes this DirectoryInfo if it is empty.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

override Delete : unit -> unit

Exception Condition
UnauthorizedAccessException

The directory contains a read-only file.

DirectoryNotFoundException

The directory described by this DirectoryInfo object does not exist or could not be found.

IOException

The directory is not empty.

-or-

The directory is the application's current working directory.

-or-

There is an open handle on the directory, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories. For more information, see How to: Enumerate Directories and Files.

SecurityException

The caller does not have the required permission.

For a list of common I/O tasks, see Common I-O Tasks.

The following example throws an exception if you attempt to delete a directory that is not empty.

No code example is currently available or this language may not be supported.

FileIOPermission

for writing directories. Associated enumeration: FileIOPermissionAccess.Write

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: