Click or drag to resize

DirectoryInfoDelete(Boolean) Method

Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.

Namespace: Crestron.SimplSharp.CrestronIO
Assembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
C#
public void Delete(
	bool recursive
)

Parameters

recursive  Boolean
true to delete this directory, its subdirectories, and all files; otherwise, false.
Exceptions
ExceptionCondition
InvalidDirectoryLocationExceptionThe specified directory can not be deleted.
IOExceptionFile system error.
DirectoryNotFoundExceptionThe current directory does not Exist.
SecurityExceptionThe user does not have the required permissions to delete this directory.
Example
using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO;; public class DeleteTest { public static void Main() { // Make a reference to a directory. DirectoryInfo info = new DirectoryInfo("/User/myDir"); // Create the directory only if it does not already exist. if (info.Exists == false) info.Create(); // Create a subdirectory in the directory just created. DirectoryInfo dis = info.CreateSubdirectory("SubDir"); // Process that directory as required. // ... // Delete the subdirectory. The true indicates that if subdirectories // or files are in this directory, they are to be deleted as well. dis.Delete(true); // Delete the directory. di.Delete(true); } }

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also