using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner { public partial class NewFileName : Form { string folderPath = ""; string PathName = ""; public string ChangePathName = ""; public bool Save = false; Hashtable table; public NewFileName(string a_Route,string a_PathName) { folderPath = a_Route; PathName = a_PathName; ChangePathName = a_PathName; InitializeComponent(); #region 国际化语言 OTSCommon.Language lan = new OTSCommon.Language(this); table = lan.GetNameTable(this.Name); #endregion } private void button1_Click(object sender, EventArgs e) { // 获取文件夹中的所有文件信息 FileInfo[] files = new DirectoryInfo(folderPath).GetFiles("*.xml", SearchOption.AllDirectories); // 遍历文件信息数组并打印出文件名 foreach (FileInfo file in files) { if (file.Name == textBox1.Text + ".xml") { MessageBox.Show(table["name_repeat"].ToString()); return; } } ChangePathName = textBox1.Text + ".xml"; Save = true; this.Close(); } private void NewFileName_Load(object sender, EventArgs e) { } } }