NewFileName.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
  13. {
  14. public partial class NewFileName : Form
  15. {
  16. string folderPath = "";
  17. string PathName = "";
  18. public string ChangePathName = "";
  19. public bool Save = false;
  20. Hashtable table;
  21. public NewFileName(string a_Route,string a_PathName)
  22. {
  23. folderPath = a_Route;
  24. PathName = a_PathName;
  25. ChangePathName = a_PathName;
  26. InitializeComponent();
  27. #region 国际化语言
  28. OTSCommon.Language lan = new OTSCommon.Language(this);
  29. table = lan.GetNameTable(this.Name);
  30. #endregion
  31. }
  32. private void button1_Click(object sender, EventArgs e)
  33. {
  34. // 获取文件夹中的所有文件信息
  35. FileInfo[] files = new DirectoryInfo(folderPath).GetFiles("*.xml", SearchOption.AllDirectories);
  36. // 遍历文件信息数组并打印出文件名
  37. foreach (FileInfo file in files)
  38. {
  39. if (file.Name == textBox1.Text + ".xml")
  40. {
  41. MessageBox.Show(table["name_repeat"].ToString());
  42. return;
  43. }
  44. }
  45. ChangePathName = textBox1.Text + ".xml";
  46. Save = true;
  47. this.Close();
  48. }
  49. private void NewFileName_Load(object sender, EventArgs e)
  50. {
  51. }
  52. }
  53. }