private static void DeleteFolder(string dir) { string[] fileSystemEntries = System.IO.Directory.GetFileSystemEntries(dir); for (int i = 0; i < fileSystemEntries.Length; i++) { string text = fileSystemEntries[i]; if (System.IO.File.Exists(text)) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(text); if (fileInfo.Attributes.ToString().IndexOf("Readonly") != 1) { fileInfo.Attributes = System.IO.FileAttributes.Normal; } System.IO.File.Delete(text); } else { ManageDistributor.DeleteFolder(text); } } System.IO.Directory.Delete(dir); }
private bool DeleteDistributorFile(int distributorUserId) { bool result = false; string text = this.Page.Request.MapPath(Globals.ApplicationPath + "/Storage/sites/") + distributorUserId; string text2 = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/sites/") + distributorUserId; if (System.IO.Directory.Exists(text) && System.IO.Directory.Exists(text2)) { try { ManageDistributor.DeleteFolder(text); ManageDistributor.DeleteFolder(text2); result = true; return(result); } catch { result = false; return(result); } } result = true; return(result); }