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 JsonResult CreateNewFolder(String virtualPath, String userName, String folderName) { String physicalPath = UtilityOperations.GetServerMapPath(virtualPath); String decodePath = UtilityOperations.DecodePath(physicalPath, Server); String folderPath = Path.Combine(decodePath, folderName); String retJsonMsg = ""; if (folderPath != "\\") { if (!Directory.Exists(folderPath)) { DocumentsOperations docOps = new DocumentsOperations(); docOps.InsertNewFolder(virtualPath, folderPath, userName, folderName); } else { retJsonMsg += "Folder name already exists. Please enter a different folder name"; } } return(new JsonResult() { Data = retJsonMsg }); }