DirectoryInfoDelete(Boolean) Method |
Deletes this instance of a
DirectoryInfo, specifying whether to delete subdirectories and files.
Namespace: Crestron.SimplSharp.CrestronIOAssembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntaxpublic void Delete(
bool recursive
)
Parameters
- recursive Boolean
- true to delete this directory, its subdirectories, and all files; otherwise, false.
Exceptions
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