diff --git a/SGGL/BLL/PHTGL/ContractCompile/ContractReviewService.cs b/SGGL/BLL/PHTGL/ContractCompile/ContractReviewService.cs index 6afb389e..264057b4 100644 --- a/SGGL/BLL/PHTGL/ContractCompile/ContractReviewService.cs +++ b/SGGL/BLL/PHTGL/ContractCompile/ContractReviewService.cs @@ -659,12 +659,36 @@ namespace BLL string projectname = ProjectService.GetProjectNameByProjectId(getFireWork.ProjectId); string rootPath = Funs.RootPath; - string startPath = rootPath + "File\\Word\\PHTGL\\" + getFireWork.ContractNum + "-" + projectname + "-" + getFireWork.ContractName + "-合同管理资料"; + // 清理路径中的非法字符 + string CleanFileName(string input) + { + if (string.IsNullOrEmpty(input)) return "Unknown"; + + char[] invalidChars = Path.GetInvalidFileNameChars(); + char[] invalidPathChars = Path.GetInvalidPathChars(); + + string result = input; + foreach (char c in invalidChars) + { + result = result.Replace(c.ToString(), "_"); + } + foreach (char c in invalidPathChars) + { + result = result.Replace(c.ToString(), "_"); + } + return result; + } + + string cleanContractNum = CleanFileName(getFireWork.ContractNum); + string cleanProjectName = CleanFileName(projectname); + string cleanContractName = CleanFileName(getFireWork.ContractName); + + string startPath = rootPath + "File\\Word\\PHTGL\\" + cleanContractNum + "-" + cleanProjectName + "-" + cleanContractName + "-合同管理资料"; if (!Directory.Exists(startPath)) { Directory.CreateDirectory(startPath); } - string zipPath = rootPath + "File\\Word\\PHTGL\\" + getFireWork.ContractNum + "-" + projectname + "-" + getFireWork.ContractName + "-合同管理资料.zip"; + string zipPath = rootPath + "File\\Word\\PHTGL\\" + cleanContractNum + "-" + cleanProjectName + "-" + cleanContractName + "-合同管理资料.zip"; switch (getFireWork.ConfirmWay) { case "1":