public ActionResult DeleteConfirmed(string fileName) { var csvFile = new CsvFileViewModel(); try { if (string.IsNullOrWhiteSpace(fileName)) { ViewBag.Error = _localizer["EmptyFileName"]; return(View(csvFile)); } var csvDirectoryPath = Tools.Directory.DirectoryTools.GetCsvDirectoryPath(_configuration); var fullFilePath = Path.Combine(csvDirectoryPath, fileName); if (!System.IO.File.Exists(fullFilePath)) { ViewBag.Error = string.Format(_localizer["FileDoesntExist"], fullFilePath); return(View(csvFile)); } DeleteFile(fullFilePath); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View(csvFile)); } }
public ActionResult Delete(string fileName) { var csvFile = new CsvFileViewModel(); if (string.IsNullOrWhiteSpace(fileName)) { ViewBag.Error = _localizer["EmptyFileName"]; return(View(csvFile)); } var csvDirectoryPath = Tools.Directory.DirectoryTools.GetCsvDirectoryPath(_configuration); var fullFilePath = Path.Combine(csvDirectoryPath, fileName); if (!System.IO.File.Exists(fullFilePath)) { ViewBag.Error = string.Format(_localizer["FileDoesntExist"], fullFilePath); return(View(csvFile)); } return(View(GetCsvFile(fullFilePath))); }