public void DeleteFolder(string deleteDirectory) { if (Directory.Exists(deleteDirectory)) { foreach(string deleteFile in Directory.GetFileSystemEntries(deleteDirectory)) { if(File.Exists(deleteFile )) File.Delete(deleteFile ); else DeleteFolder(deleteFile ); } Directory.Delete(deleteDirectory); } }