private bool DeleteFileFromLocalDisk(string fileName, EditionFileType editionFileType) { var path = Server.MapPath("~/" + editionFileType.FileFullNameInternal(fileName)); if (!System.IO.File.Exists(path)) { var log = CreateInternalLog($"File not found on {path}!"); ExternalLogHelper.Log(log, LoggingEventType.Error); return(false); } try { System.IO.File.Delete(path); return(true); } catch (Exception exc) { var log = CreateInternalLog(exc); ExternalLogHelper.Log(log, LoggingEventType.Error); return(false); } }
private FileOperationResult SaveFileToLocalDisk(EditionFileType fileType, string newFileName, HttpPostedFileBase file) { var path = Server.MapPath("~/" + fileType.FileFullNameInternal(newFileName)); if (System.IO.File.Exists(path)) { return(new FileOperationResult { Result = OperationResult.AlreadyExists }); } try { file.SaveAs(path); return(new FileOperationResult { Result = OperationResult.Succeeded, Message = path }); } catch (Exception exc) { var log = CreateInternalLog(exc); ExternalLogHelper.Log(log, LoggingEventType.Error); return(new FileOperationResult { Result = OperationResult.Failed, Message = exc.Message }); } }