private void DeleteFiles(string dir) { DirectoryInfo di = new DirectoryInfo(dir); if (di.GetDirectories().Length == 0 && di.GetFiles().Length == 0) return; foreach (DirectoryInfo d in di.GetDirectories()) { DeleteFiles(d.FullName); } foreach (FileInfo fi in di.GetFiles()) { fi.Delete(); } di.Delete(); }