C# DirectoryInfo Delete(Boolean)

Description

DirectoryInfo Delete(Boolean) Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.

Syntax

DirectoryInfo.Delete(Boolean) has the following syntax.


public void Delete(
  bool recursive
)

Parameters

DirectoryInfo.Delete(Boolean) has the following parameters.

  • recursive - true to delete this directory, its subdirectories, and all files; otherwise, false.

Returns

DirectoryInfo.Delete(Boolean) method returns

Example

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


using System;//from   w w w  .  ja v  a 2s  .  c om
using System.IO;

public class DeleteTest 
{
    public static void Main() 
    {
        DirectoryInfo di = new DirectoryInfo("TempDir");
        di.Delete(true);
    }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter