public void Test_GetFileNames() { var result = DirectoryUtil.GetFileNames(Directory.GetCurrentDirectory()); foreach (var item in result) { Output.WriteLine(item); } }
private void simpleButton3_Click(object sender, EventArgs e) { string path = txtPath.Text.Trim(); if (string.IsNullOrEmpty(path)) { path = FileDialogHelper.OpenDir(); } string fileRecord = "F:\\oldfile.txt"; string fileNewReocrd = "F:\\newfile.txt"; if (FileUtil.IsExistFile(fileRecord)) { FileUtil.DeleteFile(fileRecord); } FileUtil.CreateFile(fileRecord); if (FileUtil.IsExistFile(fileNewReocrd)) { FileUtil.DeleteFile(fileNewReocrd); } FileUtil.CreateFile(fileNewReocrd); Int32 copyCount = 0; if (!string.IsNullOrEmpty(path)) { string[] files = DirectoryUtil.GetFileNames(path, "*", true); foreach (var file in files) { FileUtil.AppendText(fileRecord, file + "\r\n", Encoding.UTF8); string oldfilerelatefile = file.Replace(path + "\\", ""); string newfllerelatefile = oldfilerelatefile.Replace("\\", "_"); if (FileUtil.IsExistFile(file) && oldfilerelatefile != newfllerelatefile) { File.Move(file, path + "\\" + newfllerelatefile); copyCount++; } } files = DirectoryUtil.GetFileNames(path, "*", true); foreach (var file in files) { FileUtil.AppendText(fileNewReocrd, file + "\r\n", Encoding.UTF8); } } MessageDxUtil.ShowTips("操作完成, 一共成功复制" + copyCount + "个文件"); }
/// <summary> /// 列出目录的文件路径或者目录 /// </summary> /// <param name="filePath">指定文件路径</param> /// <param name="isDir">是否列出目录,默认为false,返回文件列表</param> /// <returns></returns> public List <string> GetFileOrDirList(string filePath, bool isDir = false) { List <string> list = new List <string>(); try { var array = isDir ? DirectoryUtil.GetDirectories(filePath) : DirectoryUtil.GetFileNames(filePath); if (array != null) { list.AddRange(array); } } catch (Exception ex) { LogTextHelper.Error("GetFileOrDirList列出目录的文件路径出错:" + ex.Message); } return(list); }
private void btnModField_Click(object sender, EventArgs e) { StdFieldInfo aftermodstdFieldInfo = new StdFieldInfo(); aftermodstdFieldInfo.Gid = _beforemodstdFieldInfo.Gid; aftermodstdFieldInfo.Name = txtName.Text.Trim(); aftermodstdFieldInfo.ChineseName = txtChineseName.Text.Trim(); aftermodstdFieldInfo.DataType = lueFieldType.EditValue.ToString(); StringBuilder content = new StringBuilder(); #region 检查一下字段是否存在 foreach (StdFieldInfo dataTypeInfo in _lstDataTypeInfo) { if (string.IsNullOrEmpty(dataTypeInfo.Gid)) { continue; } // 与别的字段重名,不允许修改 if (string.Equals(aftermodstdFieldInfo.Name, dataTypeInfo.Name) && !string.Equals(_beforemodstdFieldInfo.Name, dataTypeInfo.Name)) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_ERR, "该标准字段已存在,不允许修改", typeof(FrmModField)); MessageDxUtil.ShowWarning("该标准字段已存在,不允许修改"); return; } } #endregion #region 取project.xml 判断当前数据库 XmlHelper xmlprojectthelper = new XmlHelper(@"XML\project.xml"); XmlNodeList xmlprejectNodeLst = xmlprojectthelper.Read("datatype"); if (xmlprejectNodeLst.Count == 0) { return; } XmlNode xn1project = xmlprejectNodeLst[0]; // 将节点转换为元素,便于得到节点的属性值 XmlElement xeproject = (XmlElement)xn1project; // 得到DataTypeInfo节点的所有子节点 XmlNodeList xnl0project = xeproject.ChildNodes; string dbType = xnl0project.Item(4).InnerText; #endregion #region 生成SQL文件 if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name) || !string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType)) { // SQLServer 修改字段 exec sp_rename '表名.列名','新列名' -- 注意,单引号不可省略。 // SQLServer 修改字段类型 alter table 表名 alter column 字段名 type not null // MySql 修改字段 ALTER TABLE 表名 CHANGE 旧字段名 新字段名 字段类型 // MySql 修改字段类型 ALTER TABLE 表名 CHANGE 字段名 字段名 新字段类型 string saveFile = FileDialogHelper.SaveText("更新字段.sql", "C:\\myares\\"); if (!string.IsNullOrEmpty(saveFile)) { String[] sqltablefileNames = DirectoryUtil.GetFileNames(@"XML\", "*.table", true); foreach (string tablefileName in sqltablefileNames) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); XmlHelper xmltablehelper = new XmlHelper(tablefileName); try { XmlNodeList xmlNodeLst = xmltablehelper.Read("datatype/fieldsinfo"); for (Int32 i = 0; i < xmlNodeLst.Count; i++) { // 字段变更 if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name) && !string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name)) { #region 读取Table.xml 配置信息 XmlHelper xmltableshelper = new XmlHelper(@"XML\tables.xml"); XmlNodeList xmlNodeLst22 = xmltableshelper.Read("datatype/tabletype"); Dictionary <string, string> guidGroup = new Dictionary <string, string>(); Dictionary <string, string> tableGroup = new Dictionary <string, string>(); guidGroup.Clear(); tableGroup.Clear(); foreach (XmlNode xn1 in xmlNodeLst22) { // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 获取字符串中的英文字母 [a-zA-Z]+ string GroupEnglishName = CRegex.GetText(xe.GetAttribute("name").ToString(), "[a-zA-Z]+", 0); guidGroup.Add(xe.GetAttribute("gid").ToString(), string.Format("{0}{1}_", Const.TablePre, GroupEnglishName)); } XmlNodeList xmlNodeLst2 = xmltableshelper.Read("datatype/dataitem"); foreach (XmlNode xn1 in xmlNodeLst2) { // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 得到Type和ISBN两个属性的属性值 // 得到ConstantInfo节点的所有子节点 XmlNodeList xnl0 = xe.ChildNodes; tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]); } #endregion string tableName = xmltablehelper.Read("datatype/basicinfo/item/name").Item(0).InnerText; content.Append(string.Format("exec sp_rename '{0}.{1}','{2}';\r\nGO\r\n\r\n", tableGroup[tableName] + tableName, _beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name)); } if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name) && !string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType)) { #region 先读取datatype.xml 在读取defaulttype.xml 然后Linq 查询保存到数据字典dic中 XmlHelper xmldatatypehelper = new XmlHelper(@"XML\datatype.xml"); XmlNodeList xmldatatypeNodeLst = xmldatatypehelper.Read("datatype"); List <DataTypeInfo> dataTypeInfoList = new List <DataTypeInfo>(); foreach (XmlNode xn1 in xmldatatypeNodeLst) { DataTypeInfo dataTypeInfo = new DataTypeInfo(); // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 得到Type和ISBN两个属性的属性值 dataTypeInfo.Gid = xe.GetAttribute("gid").ToString(); // 得到DataTypeInfo节点的所有子节点 XmlNodeList xnl0 = xe.ChildNodes; dataTypeInfo.Name = xnl0.Item(0).InnerText; dataTypeInfo.StdType = xnl0.Item(2).InnerText; dataTypeInfo.Length = xnl0.Item(3).InnerText; dataTypeInfo.Precision = xnl0.Item(4).InnerText; dataTypeInfoList.Add(dataTypeInfo); } XmlHelper defaulttypexmlHelper = new XmlHelper(@"XML\defaulttype.xml"); XmlNodeList defaulttypexmlNodeLst = defaulttypexmlHelper.Read("datatype"); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var dataTypeInfo in dataTypeInfoList) { foreach (XmlNode xn1 in defaulttypexmlNodeLst) { // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 得到DataTypeInfo节点的所有子节点 XmlNodeList xnl0 = xe.ChildNodes; string value = string.Empty; if (dbType == "Oracle") { value = xnl0.Item(2).InnerText; } else if (dbType == "Mysql") { value = xnl0.Item(3).InnerText; } else if (dbType == "DB2") { value = xnl0.Item(4).InnerText; } else if (dbType == "SqlServer") { value = xnl0.Item(5).InnerText; } else if (dbType == "Sqlite") { value = xnl0.Item(6).InnerText; } else if (dbType == "Access") { value = xnl0.Item(7).InnerText; } // 找到匹配记录 if (dataTypeInfo.StdType == xnl0.Item(0).InnerText) { if (value.Contains("$L")) { if (String.Empty == dataTypeInfo.Length) { value = value.Replace("$L", "0"); } else { value = value.Replace("$L", dataTypeInfo.Length); } } if (value.Contains("$P")) { if (String.Empty == dataTypeInfo.Precision) { value = value.Replace("$P", "0"); } else { value = value.Replace("$P", dataTypeInfo.Precision); } } dict.Add(dataTypeInfo.Name, value); } } } #endregion #region 读取Table.xml 配置信息 XmlHelper xmltableshelper = new XmlHelper(@"XML\tables.xml"); XmlNodeList xmlNodeLst22 = xmltableshelper.Read("datatype/tabletype"); Dictionary <string, string> guidGroup = new Dictionary <string, string>(); Dictionary <string, string> tableGroup = new Dictionary <string, string>(); guidGroup.Clear(); tableGroup.Clear(); foreach (XmlNode xn1 in xmlNodeLst22) { // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 获取字符串中的英文字母 [a-zA-Z]+ string GroupEnglishName = CRegex.GetText(xe.GetAttribute("name").ToString(), "[a-zA-Z]+", 0); guidGroup.Add(xe.GetAttribute("gid").ToString(), string.Format("{0}{1}_", Const.TablePre, GroupEnglishName)); } XmlNodeList xmlNodeLst2 = xmltableshelper.Read("datatype/dataitem"); foreach (XmlNode xn1 in xmlNodeLst2) { // 将节点转换为元素,便于得到节点的属性值 XmlElement xe = (XmlElement)xn1; // 得到Type和ISBN两个属性的属性值 // 得到ConstantInfo节点的所有子节点 XmlNodeList xnl0 = xe.ChildNodes; tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]); } #endregion string tableName = xmltablehelper.Read("datatype/basicinfo/item/name").Item(0).InnerText; content.Append(string.Format("alter table {0} alter column {1} {2};\r\nGO\r\n\r\n", tableGroup[tableName] + tableName, aftermodstdFieldInfo.Name, dict[aftermodstdFieldInfo.DataType])); } } xmltablehelper.Save(false); } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField)); MessageDxUtil.ShowError(ex.Message); } LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); } FileUtil.WriteText(saveFile, content.ToString(), Encoding.UTF8); if (MessageDxUtil.ShowYesNoAndTips("保存成功,是否打开文件?") == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start(saveFile); } } } #endregion #region 修改*.table 字段 String[] tablefileNames = DirectoryUtil.GetFileNames(@"XML\", "*.table", true); foreach (string tablefileName in tablefileNames) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); XmlHelper xmltablehelper = new XmlHelper(tablefileName); try { #region 更新数据 if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name)) { XmlNodeList xmlNodeLst = xmltablehelper.Read("datatype/fieldsinfo"); for (Int32 i = 0; i < xmlNodeLst.Count; i++) { if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name)) { xmlNodeLst[i].ChildNodes.Item(0).InnerText = aftermodstdFieldInfo.Name; } } } xmltablehelper.Save(false); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField)); MessageDxUtil.ShowError(ex.Message); } LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); } #endregion #region 修改*.entity 字段 String[] entityfileNames = DirectoryUtil.GetFileNames(@"XML\", "*.entity", true); foreach (string entityfileName in entityfileNames) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", entityfileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); XmlHelper xmlentityhelper = new XmlHelper(entityfileName); try { #region 更新数据 if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name)) { XmlNodeList xmlNodeLst = xmlentityhelper.Read("datatype/fieldsinfo"); for (Int32 i = 0; i < xmlNodeLst.Count; i++) { if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name)) { xmlNodeLst[i].ChildNodes.Item(0).InnerText = aftermodstdFieldInfo.Name; } } } xmlentityhelper.Save(false); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField)); MessageDxUtil.ShowError(ex.Message); } LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", entityfileName, _beforemodstdFieldInfo.Name), typeof(FrmModField)); } #endregion #region 修改stdfield.xml文件 XmlHelper xmlstdfieldhelper = new XmlHelper(@"XML\stdfield.xml"); try { #region 更新数据 if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name)) { xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/name", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.Name); } if (!string.Equals(_beforemodstdFieldInfo.ChineseName, aftermodstdFieldInfo.ChineseName)) { xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/chineseName", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.ChineseName); } if (!string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType)) { xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/datatype", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.DataType); } xmlstdfieldhelper.Save(false); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField)); MessageDxUtil.ShowError(ex.Message); } #endregion this.Close(); }
private void btnBuild_Click(object sender, EventArgs e) { string[] filesNames = DirectoryUtil.GetFileNames(txtFilePath.Text.Trim()); }
/// <summary> /// 生成底单 /// </summary> public void BuildImage() { var stopWatch = new Stopwatch(); stopWatch.Start(); UpdateControlText1 updateControl = updateControlText; try { if (_list == null || _list.Count == 0) { return; } for (int i = 0; i < _list.Count; i++) { if (string.IsNullOrEmpty(_list[i].BillCode)) { continue; } _printFileName = !string.IsNullOrEmpty(_list[i].BillCode) ? _list[i].BillCode : DateTime.Now.Ticks.ToString(); _tempList.Add(_list[i]); ++_tempIndex; // http://blog.csdn.net/szstephenzhou/article/details/12838961 // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。 if (this.IsHandleCreated) { this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count)); } // 2016-1-31下午 这一行代码一定要写,因为要导出模板的面单图片,所以一定要设置true,如果不想要就设置成false就行了,grid++的客服还是很不错的,qq:grid++ report 641243789 // _report.BackImagePrint = true; // 直接调用ExportDirect方法执行导出任务,这里我只是导出图片哦 _report.ExportDirect(GRExportType.gretIMG, _printFileName, false, false); _tempList.Clear(); } if (_tempIndex > 0) { if (ckAddSystemWaterMark.Checked) { string waterMarkFolder = BillPrintHelper.SaveFilePath + "\\水印底单"; if (!DirectoryUtil.IsExistDirectory(waterMarkFolder)) { DirectoryUtil.CreateDirectory(waterMarkFolder); } var files = DirectoryUtil.GetFileNames(BillPrintHelper.SaveFilePath); foreach (string file in files) { if (Utilities.FileUtil.FileIsExist(file)) { // img对象一定要释放,不然内存上升,杨恒连,2016年7月24日15:25:35 using (var img = ImageHelper.WatermarkText(Image.FromFile(file), BaseSystemInfo.SoftFullName, ImageHelper.WatermarkPosition.BottomRight, new Font("Verdana", 10, FontStyle.Bold), new SolidBrush(Color.Blue))) { string fileName = Utilities.FileUtil.GetFileNameNoExtension(file); img.Save(string.Format(waterMarkFolder + "\\" + fileName + ".png", fileName)); } } } } // alertBuildImageInfo.Show(this, "生成底单", string.Format("成功生成{0}张底单图片", _list.Count)); // XtraMessageBox.Show(string.Format("成功生成{0}张底单图片,是否打开文件夹查看?", _list.Count), AppMessage.MSG0000, MessageBoxButtons.YesNo, MessageBoxIcon.Question); //if ( == DialogResult.Yes) //{ // Process.Start(BillPrintHelper.SaveFilePath); //} } } catch (Exception exception) { // XtraMessageBox.Show(exception.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); LogUtil.WriteException(exception); } finally { btnBuildImage.Enabled = true; _tempIndex = 0; if (_list != null) { stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; string elapsedTime = string.Format("{0}分{1}秒{2}毫秒", ts.Minutes, ts.Seconds, ts.Milliseconds); // http://blog.csdn.net/szstephenzhou/article/details/12838961 // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。 if (this.IsHandleCreated) { this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count) + " 耗时:" + elapsedTime); } } } }
private void btnBuildOk_Click(object sender, EventArgs e) { Task task1 = new Task(() => { LogHelper.WriteLog(LogLevel.LOG_LEVEL_INFO, "START [开始生成OK标志]", typeof(FrmDealConsignment)); AddLog(LogLevel.LOG_LEVEL_INFO, "START [开始生成OK标志]"); string buildPath = txtBuildOk.Text.Replace("yyyyMMdd", txtTDay.Text.Trim()).Trim(); string build004Path = txtBuild004Ok.Text.Replace("yyyyMMdd", txtTDay.Text.Trim()).Trim(); string build012Path = txtBuild012Ok.Text.Replace("yyyyMMdd", txtTDay.Text.Trim()).Trim(); string TDay = txtTDay.Text.Trim(); string T1Day = txtT1Day.Text.Trim(); string[] ExcludeItems = txtExcludeItems.Text.Trim().Split(','); if (string.IsNullOrEmpty(buildPath)) { txtcheckPath.Focus(); MessageDxUtil.ShowError("生成路径 未配置"); return; } if (!DirectoryUtil.IsExistDirectory(buildPath)) { txtcheckPath.Focus(); MessageDxUtil.ShowError(string.Format("配置生成路径不存在 BuildPath: {0}", buildPath)); return; } if (string.IsNullOrEmpty(build004Path)) { txtcheckPath.Focus(); MessageDxUtil.ShowError("3T_004_hq 未配置"); return; } if (!DirectoryUtil.IsExistDirectory(build004Path)) { txtcheckPath.Focus(); MessageDxUtil.ShowError(string.Format("配置 3T_004_hq 不存在 Build004Path: {0}", build004Path)); return; } if (string.IsNullOrEmpty(build012Path)) { txtcheckPath.Focus(); MessageDxUtil.ShowError("3T_012_HQ 未配置"); return; } if (!DirectoryUtil.IsExistDirectory(build012Path)) { txtcheckPath.Focus(); MessageDxUtil.ShowError(string.Format("配置 3T_012_HQ 不存在 Build012Path: {0}", build012Path)); return; } // 遍历全部的文件夹并删除已经存在的OK标志 String[] files = DirectoryUtil.GetFileNames(buildPath, "*.ok", true); foreach (String file in files) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("删除文件OK文件 {0}", file), typeof(FrmDealConsignment)); FileUtil.DeleteFile(file); } Int32 buildOkCount = 0; Int32 build004OkCount = 0; Int32 build012OkCount = 0; // 遍历全部的文件夹并生成OK标志 files = DirectoryUtil.GetFileNames(buildPath, "*.*", true); foreach (String file in files) { // 对于排除的项目不生成ok标志 bool isSkip = false; foreach (string item in ExcludeItems) { if (file.Contains(item)) { isSkip = true; continue; } } if (isSkip) { continue; } string fileOk = string.Format("{0}.ok", file); AddLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("生成文件OK文件 {0}", fileOk)); FileUtil.CreateFile(fileOk); buildOkCount++; } // 遍历 3T_004_hq 下 T+1对应的文件生成OK标志 files = DirectoryUtil.GetFileNames(build004Path, string.Format("*{0}*.ok", T1Day), true); foreach (String file in files) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("删除004文件OK文件 {0}", file), typeof(FrmDealConsignment)); FileUtil.DeleteFile(file); } // 遍历全部的文件夹并生成OK标志 files = DirectoryUtil.GetFileNames(build004Path, string.Format("*{0}*.*", T1Day), true); foreach (String file in files) { string fileOk = string.Format("{0}.ok", file); AddLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("生成004文件OK文件 {0}", fileOk)); //LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("生成004文件OK文件 {0}", fileOk), typeof(FrmDealConsignment)); FileUtil.CreateFile(fileOk); build004OkCount++; } // 遍历 3T_012_HQ 下 T+1对应的文件生成OK标志 files = DirectoryUtil.GetFileNames(build012Path, string.Format("*{0}*.ok", T1Day), true); foreach (String file in files) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("删除012文件OK文件 {0}", file), typeof(FrmDealConsignment)); FileUtil.DeleteFile(file); } // 遍历全部的文件夹并生成OK标志 files = DirectoryUtil.GetFileNames(build012Path, string.Format("*{0}*.*", T1Day), true); foreach (String file in files) { string fileOk = string.Format("{0}.ok", file); AddLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("生成012文件OK文件 {0}", fileOk)); LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("生成012文件OK文件 {0}", fileOk), typeof(FrmDealConsignment)); FileUtil.CreateFile(fileOk); build012OkCount++; } string str = string.Format("代销处理完成! 生成路径生成OK共计{0}条记录 3T_004_hq生成OK共计{1}条记录 3T_012_HQ生成OK共计{2}条记录", buildOkCount, build004OkCount, build012OkCount); LogHelper.WriteLog(LogLevel.LOG_LEVEL_INFO, "END [" + str + "]", typeof(FrmDealConsignment)); AddLog(LogLevel.LOG_LEVEL_INFO, "END [" + str + "]"); MessageDxUtil.ShowTips(str); }); task1.Start(); }