public IActionResult DeleteDirectory(string dir) { var fileManager = new FileManager(dir, Request.Path.ToString(), _appEnvironment.ApplicationBasePath); Directory.Delete(fileManager.FileSystemPath + dir, true); TempData["MessageBus"] = "The folder was deleted successfully."; return RedirectToAction("Index", new { dir = dir.Substring(0, dir.LastIndexOf("/")) }); }
public IActionResult CreateDirectory(string dir, FileManagerDirectory directory) { if (!ModelState.IsValid) return View(directory); var fileManager = new FileManager(dir, Request.Path.ToString(), _appEnvironment.ApplicationBasePath); var newDirectoryName = directory.Name.Slugify(); Directory.CreateDirectory(fileManager.FileSystemPath + fileManager.CurrentDirectory + "/" + newDirectoryName); TempData["MessageBus"] = "The Directory was created successfully."; return RedirectToAction("Index", new { dir = fileManager.CurrentDirectory + "/" + newDirectoryName }); }
public IActionResult Index(string dir) { var fileManager = new FileManager(dir, Request.Path.ToString(), _appEnvironment.ApplicationBasePath); var fileManagerViewMode = "Details"; var fileManagerViewModeCookie = Request.Cookies["FileManagerViewMode"]; if (!string.IsNullOrWhiteSpace(fileManagerViewModeCookie)) fileManagerViewMode = fileManagerViewModeCookie; ViewBag.FileManagerViewMode = fileManagerViewMode; return View(fileManager); }
public IActionResult BulkDelete(string[] deletePaths) { // since all of the paths start from the same directory it should be safe to use the first path in the array to establish the current directory var fileManager = new FileManager(deletePaths[0], Request.Path.ToString(), _appEnvironment.ApplicationBasePath); foreach (string s in deletePaths) { var deletePath = fileManager.FileSystemPath + s; if ((System.IO.File.GetAttributes(deletePath) & FileAttributes.Directory) == FileAttributes.Directory) Directory.Delete(deletePath, true); else System.IO.File.Delete(deletePath); } TempData["MessageBus"] = "The files were deleted successfully."; var returnDir = deletePaths[0].Substring(0, deletePaths[0].LastIndexOf("/")); return RedirectToAction("Index", new { dir = returnDir }); }
public IActionResult DeleteFile(string file) { var fileManager = new FileManager(file, Request.Path.ToString(), _appEnvironment.ApplicationBasePath); System.IO.File.Delete(fileManager.FileSystemPath + file); TempData["MessageBus"] = "The file was deleted successfully."; return RedirectToAction("Index", new { dir = file.Substring(0, file.LastIndexOf("/")) }); }