/// <summary> /// 彻底删除文件命令 /// </summary> public void Remove(RemoveFileCmd cmd) { if (cmd.FilePaths == null || cmd.FilePaths.Count == 0) { throw new Exception("文件路径数量不能为空!"); } foreach (var filePath in cmd.FilePaths) { if (string.IsNullOrEmpty(filePath)) { continue; } var uri = new Uri(filePath); var fileInfo = _env.WebRootFileProvider.GetFileInfo(uri.AbsolutePath); if (fileInfo.Exists) { File.Delete(fileInfo.PhysicalPath); } } }
private IEnumerable <RemoveFileCmd> ReadRemoveFileCmds(XElement source) { var result = new List <RemoveFileCmd>(); var cmdElementsCollection = source.Elements(CmdEntryType.RemoveFile.Name); foreach (var cmdElement in cmdElementsCollection) { var sourcePath = cmdElement.Attribute("sourcePath").ValueNullSafe(); var isCritical = cmdElement.Attribute("isCritical").ValueOr <bool>(criticalCmdsDefault); var priority = cmdElement.Attribute("priority").ValueOr <int>(1); var newCmd = new RemoveFileCmd(); newCmd.SourcePath = new InstallEntityPath(sourcePath); newCmd.IsCritical = isCritical; newCmd.Priority = priority; result.Add(newCmd); } return(result); }
public ResponseDto <string> Remove([FromBody] RemoveFileCmd cmd) { _fileAppService.Remove(cmd); return(Success("删除成功!")); }