public void delfile(string path) { if (Directory.Exists(path)) { foreach (string d in Directory.GetFileSystemEntries(path)) { if (File.Exists(d)) File.Delete(d); else delfile(path); } Directory.Delete(path, true); } }