2014/07/29

How to remove directory with all its files and subdirs recursively ?

public static void DeleteDirCompletely(string dirPath)
{
DirectoryInfo di = new DirectoryInfo(dirPath);
foreach (var file in di.GetFiles())
File.Delete(file.FullName);
foreach (var dir in di.GetDirectories())
Directory.Delete(dir.FullName);
Directory.Delete(dirPath);
}
view raw gistfile1.cs hosted with ❤ by GitHub

No comments:

Post a Comment