public ActionResult CommonFolderMgt(CommonFolderManagement cfm, String submit, String tableSelectedFolder) { DocumentsOperations docOps = new DocumentsOperations(); String virtualPath = "", physicalPath = "", folderPath = ""; switch (submit) { case "Create": virtualPath = UtilityOperations.GetDockerCommonFolderPath(); physicalPath = UtilityOperations.GetServerMapPath(virtualPath); folderPath = Path.Combine(UtilityOperations.DecodePath(physicalPath, Server), cfm.FolderName); if (folderPath != "\\") { if (!Directory.Exists(folderPath)) { docOps.InsertNewFolder(virtualPath, folderPath, HttpContext.User.Identity.Name, cfm.FolderName); } else { TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder already existed."; } } break; case "Edit": return(RedirectToAction("EditCommonFolder", new { virtualPath = tableSelectedFolder })); case "Delete": physicalPath = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(tableSelectedFolder), Server); FileAttributes attr = System.IO.File.GetAttributes(physicalPath); if (Directory.Exists(physicalPath)) { if (docOps.GetFilesStartsWithVirtualPath(tableSelectedFolder) != null) { docOps.DeleteFile(tableSelectedFolder); } Directory.Delete(physicalPath, true); } else { TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder not exist in the system."; } break; } return(RedirectToAction("CommonFolderMgt")); }
public ActionResult CommonFolderMgt() { CommonFolderManagement cfm = new CommonFolderManagement(); List <CommonFolderAssignment> cfaList = new List <CommonFolderAssignment>(); DocumentsOperations docOps = new DocumentsOperations(); foreach (var item in docOps.GetFilesStartsWithVirtualPath(UtilityOperations.GetDockerCommonFolderPath())) { cfaList.Add(new CommonFolderAssignment { FolderName = item.Name, CreatedAt = item.DateTimeUploaded.ToString(), VirtualPath = item.VirtualPath, UsersName = docOps.GetUsersNameByFileID(item.ID), RolesName = docOps.GetRolesNameByFileID(item.ID) }); } cfm.CommonFolderAssignment = cfaList; return(View(cfm)); }
public JsonResult DeleteFile(String virtualPath) { bool retJsonBool = false; if (virtualPath.Length > 1) { String physicalPath = UtilityOperations.GetServerMapPath(virtualPath); physicalPath = UtilityOperations.DecodePath(physicalPath, Server); FileAttributes attr = System.IO.File.GetAttributes(physicalPath); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (Directory.Exists(physicalPath)) { DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFilesStartsWithVirtualPath(virtualPath) != null) { docOps.DeleteFile(virtualPath); } Directory.Delete(physicalPath, true); retJsonBool = true; } } else { if (System.IO.File.Exists(physicalPath)) { DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath) != null) { docOps.DeleteFile(virtualPath); } System.IO.File.Delete(physicalPath); retJsonBool = true; } } } return(new JsonResult() { Data = retJsonBool }); }