/// <summary> /// 生成txt文件 /// </summary> /// yaoy 16.07.06 /// <param name="fileId"></param> /// <returns></returns> public string CreateTxtFile(int fileId, string message) { string fileName = string.Empty; string txtFileName = string.Empty; // 文件路径 string dirPath = HttpContext.Current.Server.MapPath(path); ICombinaData combinaComData = new CombinaComMessageData(); ICombinaData combinaPerData = new CombinaPerMessageData(); ReportFilesInfo reportFilesInfo = new DataRule().GetReportFilesInfoById(fileId); // 获取服务对象 int serviceObj = reportFilesInfo == null ? 0 : reportFilesInfo.ServiceObj; // 企业报文 if (serviceObj == 1) { txtFileName = combinaComData.BuildMessageName(fileId); } // 个人报文 if (serviceObj == 2) { txtFileName = combinaPerData.BuildMessageName(fileId); } if (!DirFile.IsExistDirectory(dirPath)) { DirFile.CreateDirectory(dirPath); } if (txtFileName != string.Empty) { fileName = txtFileName + ".txt"; string filePath = dirPath + fileName; DirFile.CreateFile(filePath); DirFile.WriteText(filePath, message, Encoding.GetEncoding("gb2312")); } return(fileName); }