Delete Directory - CSharp System.IO

CSharp examples for System.IO:DirectoryInfo

Description

Delete Directory

Demo Code


using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml;
using System.IO.Compression;
using System.IO;//from  w w w  .  j  a va 2  s.  c  o  m
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Configuration;
using System;

public class Main{
        public static void DeleteDirectory(string targetDir)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(targetDir);
            if (dirInfo.Exists)
            {
                DeleteDirectoryFiles(targetDir, true);
                dirInfo.Delete(true);
            }
        }
}

Related Tutorials