StartForm.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using System.Threading;
  6. using System.IO;
  7. using System.Linq;
  8. namespace MOTINOVA_Motor_Factory_Set
  9. {
  10. public partial class StartForm : Form
  11. {
  12. public static ftp myFtp = new ftp();
  13. public static server_cfg myServerCfg = new server_cfg();
  14. public static ImportForm ImportForm1 = new ImportForm();
  15. public static ExportForm ExportForm1 = new ExportForm();
  16. public static ManageForm ManageForm1 = new ManageForm();
  17. public static CheckForm CheckForm1 = new CheckForm();
  18. public static Enter EnterForm1 = new Enter();
  19. public static Note NoteForm = new Note();
  20. public static string UserPath = "";
  21. public StartForm()
  22. {
  23. InitializeComponent();
  24. //配置网络服务参数
  25. myServerCfg.MyServerOption(Directory.GetCurrentDirectory() + "\\Server");
  26. //配置FTP服务器
  27. myFtp.FtpOption(myServerCfg.IP, myServerCfg.Port, myServerCfg.User, myServerCfg.PassWd);
  28. //配置数据存储路径
  29. UserPath = GetLogSavePath(Directory.GetCurrentDirectory() + "\\UserPath");
  30. ImportForm1.LocalCfgFilePath = UserPath + "\\cfg\\";
  31. ImportForm1.LogSavePath = UserPath+ "\\walkTest\\";
  32. CheckForm1.LocalCfgFilePath = UserPath + "\\cfg\\";
  33. CheckForm1.LogSavePath = UserPath + "\\qcTest\\";
  34. ManageForm1.FilePath = UserPath + "\\cfg\\";
  35. ExportForm1.FilePath = UserPath + "\\cfg\\";
  36. ManageForm1.textBox_LocalPath.Text = UserPath;
  37. //检查本地文件夹
  38. if (!Directory.Exists(ImportForm1.LocalCfgFilePath))
  39. Directory.CreateDirectory(ImportForm1.LocalCfgFilePath);
  40. if (!Directory.Exists(ImportForm1.LogSavePath))
  41. Directory.CreateDirectory(ImportForm1.LogSavePath);
  42. if (!Directory.Exists(CheckForm1.LocalCfgFilePath))
  43. Directory.CreateDirectory(CheckForm1.LocalCfgFilePath);
  44. if (!Directory.Exists(CheckForm1.LogSavePath))
  45. Directory.CreateDirectory(CheckForm1.LogSavePath);
  46. if (!Directory.Exists(ManageForm1.FilePath))
  47. Directory.CreateDirectory(ManageForm1.FilePath);
  48. if (!Directory.Exists(ExportForm1.FilePath))
  49. Directory.CreateDirectory(ExportForm1.FilePath);
  50. //创建线程,定时检测网络连接状态
  51. Thread th = new Thread(NetworkCheck);
  52. th.IsBackground = true;
  53. th.Start();
  54. }
  55. //读取数据存储路径
  56. string GetLogSavePath(string fileName)
  57. {
  58. string result = "";
  59. try
  60. {
  61. //加载配置文件
  62. StreamReader objReader = new StreamReader(fileName);
  63. string sLine = "";
  64. List<string> array_CfgInfo = new List<string>();
  65. while (sLine != null)
  66. {
  67. sLine = objReader.ReadLine();
  68. array_CfgInfo.Add(sLine);
  69. }
  70. objReader.Close();
  71. result = array_CfgInfo[0].Substring(array_CfgInfo[0].LastIndexOf("=") + 1);
  72. if (result == "")
  73. {
  74. MessageBox.Show("文件加载失败,采用默认路径");
  75. result = Directory.GetCurrentDirectory();
  76. }
  77. }
  78. catch(Exception e)
  79. {
  80. MessageBox.Show("文件加载失败,采用默认路径",e.Message);
  81. result = Directory.GetCurrentDirectory();
  82. }
  83. return result;
  84. }
  85. //检查网络状态线程
  86. private void NetworkCheck()
  87. {
  88. //初始化第一次连接FTP服务器
  89. bool Result = myFtp.CheckFtp();
  90. this.Invoke((EventHandler)(delegate
  91. {
  92. if (Result == true)//服务器连接成功
  93. {
  94. label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  95. label_NetStatus.ForeColor = Color.Green;
  96. ImportForm1.label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  97. ImportForm1.label_NetStatus.BackColor = Color.Green;
  98. CheckForm1.label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  99. CheckForm1.label_NetStatus.BackColor = Color.Green;
  100. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  101. {
  102. CheckForm1.checkBox_LocalFile.Checked = false;
  103. CheckForm1.checkBox_LocalFile.Enabled = false;
  104. ImportForm1.checkBox_LocalFile.Checked = false;
  105. ImportForm1.checkBox_LocalFile.Enabled = false;
  106. }
  107. else//允许本地文件,默认在线模式
  108. {
  109. CheckForm1.checkBox_LocalFile.Checked = false;
  110. CheckForm1.checkBox_LocalFile.Enabled = true;
  111. ImportForm1.checkBox_LocalFile.Checked = false;
  112. ImportForm1.checkBox_LocalFile.Enabled = true;
  113. }
  114. //检查最新版本号,与当前版本对比
  115. string VerInfo = "";
  116. VerInfo = StartForm.myFtp.GetFileNameList(StartForm.myServerCfg.RootPath + "/version/")[0];
  117. string VerInfoCur = label_Ver.Text;
  118. if (VerInfoCur.Contains(VerInfo) == false)
  119. {
  120. MessageBox.Show("最新版本为" + VerInfo + ",请联系管理员!");
  121. this.Close();
  122. }
  123. myFtp.IsNetConnected = true;
  124. }
  125. else//服务器连接失败
  126. {
  127. label_NetStatus.Text = "网络连接失败";
  128. label_NetStatus.ForeColor = Color.Red;
  129. ImportForm1.label_NetStatus.Text = "网络连接失败";
  130. ImportForm1.label_NetStatus.BackColor = Color.Red;
  131. CheckForm1.label_NetStatus.Text = "网络连接失败";
  132. CheckForm1.label_NetStatus.BackColor = Color.Red;
  133. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  134. {
  135. CheckForm1.checkBox_LocalFile.Checked = false;
  136. CheckForm1.checkBox_LocalFile.Enabled = false;
  137. ImportForm1.checkBox_LocalFile.Checked = false;
  138. ImportForm1.checkBox_LocalFile.Enabled = false;
  139. }
  140. else//允许本地文件
  141. {
  142. CheckForm1.checkBox_LocalFile.Checked = true;
  143. CheckForm1.checkBox_LocalFile.Enabled = false;
  144. ImportForm1.checkBox_LocalFile.Checked = true;
  145. ImportForm1.checkBox_LocalFile.Enabled = false;
  146. }
  147. myFtp.IsNetConnected = false;
  148. if (MessageBox.Show("网络连接失败,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
  149. {
  150. this.Close();
  151. }
  152. }
  153. button_Export.Enabled = true;
  154. button_Import.Enabled = true;
  155. button_Mang.Enabled = true;
  156. button_Check.Enabled = true;
  157. }));
  158. //创建定时器,定时10s检查网络
  159. System.Timers.Timer timer_CheckNet = new System.Timers.Timer();
  160. timer_CheckNet.Enabled = true;
  161. timer_CheckNet.Interval = 10000;
  162. timer_CheckNet.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_CheckNet_Tick);
  163. timer_CheckNet.Start();
  164. while (true)
  165. {
  166. Thread.Sleep(1);
  167. }
  168. }
  169. //线程中定时任务,检查网络状态
  170. private void timer_CheckNet_Tick(object sender, EventArgs e)
  171. {
  172. //连接FTP服务器
  173. bool Result = myFtp.CheckFtp();
  174. this.Invoke((EventHandler)(delegate
  175. {
  176. if (Result == true)//服务器连接成功
  177. {
  178. label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  179. label_NetStatus.ForeColor = Color.Green;
  180. ImportForm1.label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  181. ImportForm1.label_NetStatus.BackColor = Color.Green;
  182. CheckForm1.label_NetStatus.Text = myServerCfg.ServerName + " | " + myServerCfg.IP + " | " + "连接成功";
  183. CheckForm1.label_NetStatus.BackColor = Color.Green;
  184. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  185. {
  186. CheckForm1.checkBox_LocalFile.Enabled = false;
  187. ImportForm1.checkBox_LocalFile.Enabled = false;
  188. }
  189. else//允许本地文件
  190. {
  191. CheckForm1.checkBox_LocalFile.Enabled = true;
  192. ImportForm1.checkBox_LocalFile.Enabled = true;
  193. }
  194. myFtp.IsNetConnected = true;
  195. //定时与服务器同步文件
  196. #if false
  197. //cfg
  198. PathSyncWithServer("/cfg");
  199. //qcTest/errorlog
  200. PathSyncWithServer("/qcTest/errorlog");
  201. //qcTest/log
  202. PathSyncWithServer("/qcTest/log");
  203. //walkTest/errorlog
  204. PathSyncWithServer("/walkTest/errorlog");
  205. //walkTest/log
  206. PathSyncWithServer("/walkTest/log");
  207. #endif
  208. }
  209. else//服务器连接失败
  210. {
  211. label_NetStatus.Text = "网络连接失败";
  212. label_NetStatus.ForeColor = Color.Red;
  213. ImportForm1.label_NetStatus.Text = "网络连接失败";
  214. ImportForm1.label_NetStatus.BackColor = Color.Red;
  215. ImportForm1.checkBox_LocalFile.Checked = true;
  216. ImportForm1.checkBox_LocalFile.Enabled = false;
  217. CheckForm1.label_NetStatus.Text = "网络连接失败";
  218. CheckForm1.label_NetStatus.BackColor = Color.Red;
  219. CheckForm1.checkBox_LocalFile.Checked = true;
  220. CheckForm1.checkBox_LocalFile.Enabled = false;
  221. myFtp.IsNetConnected = false;
  222. //不允许离线使用时检查网络
  223. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  224. {
  225. MessageBox.Show("请检查网络,或联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  226. System.Environment.Exit(0);
  227. }
  228. }
  229. }));
  230. }
  231. /// <summary>
  232. /// 获取本地和远端目录名差集,本地有但远端没有
  233. /// </summary>
  234. /// <param name="localPath">本地路径</param>
  235. /// <param name="remotePath">远端路径</param>
  236. /// <returns>差集文件夹名称集合</returns>
  237. private string[] FiltDiffDirectory(string localPath, string remotePath)
  238. {
  239. try
  240. {
  241. string[] Local = System.IO.Directory.GetDirectories(localPath);
  242. for (int i = 0; i < Local.Length; i++)
  243. Local[i] = Local[i].Substring(Local[i].LastIndexOf("\\") + 1);
  244. string[] Remote = StartForm.myFtp.GetDirectoryList(remotePath);
  245. for (int i = 0; i < Remote.Length; i++)
  246. Remote[i] = Remote[i].Substring(Remote[i].LastIndexOf("/") + 1);
  247. return Local.Except(Remote).ToList().ToArray();
  248. }
  249. catch (Exception ex)
  250. {
  251. throw new Exception("同步失败,原因: " + ex.Message);
  252. }
  253. }
  254. /// <summary>
  255. /// 获取本地和远端文件夹下目录名交集
  256. /// </summary>
  257. /// <param name="localPath"></param>
  258. /// <param name="remotePath"></param>
  259. /// <returns></returns>
  260. private string[] FiltCommonDirectory(string localPath, string remotePath)
  261. {
  262. try
  263. {
  264. string[] Local = System.IO.Directory.GetDirectories(localPath);
  265. for (int i = 0; i < Local.Length; i++)
  266. Local[i] = Local[i].Substring(Local[i].LastIndexOf("\\") + 1);
  267. string[] Remote = StartForm.myFtp.GetDirectoryList(remotePath);
  268. for (int i = 0; i < Remote.Length; i++)
  269. Remote[i] = Remote[i].Substring(Remote[i].LastIndexOf("/") + 1);
  270. return Local.Intersect(Remote).ToList().ToArray();
  271. }
  272. catch (Exception ex)
  273. {
  274. throw new Exception("同步失败,原因: " + ex.Message);
  275. }
  276. }
  277. /// <summary>
  278. /// 获取本地和远端文件名差集,本地存在而远端不存在
  279. /// </summary>
  280. /// <param name="localPath">本地路径</param>
  281. /// <param name="remotePath">远端路径</param>
  282. /// <returns>差集文件名集合</returns>
  283. private string[] FiltDiffFiles(string localPath, string remotePath)
  284. {
  285. try
  286. {
  287. string[] Local = System.IO.Directory.GetFiles(localPath);
  288. for (int i = 0; i < Local.Length; i++)
  289. Local[i] = Local[i].Substring(Local[i].LastIndexOf("\\") + 1);
  290. string[] Remote = StartForm.myFtp.GetFileNameList(remotePath);
  291. for (int i = 0; i < Remote.Length; i++)
  292. Remote[i] = Remote[i].Substring(Remote[i].LastIndexOf("/") + 1);
  293. return Local.Except(Remote).ToList().ToArray();
  294. }
  295. catch (Exception ex)
  296. {
  297. throw new Exception("同步失败,原因: " + ex.Message);
  298. }
  299. }
  300. /// <summary>
  301. /// 获取本地和远端文件名交集
  302. /// </summary>
  303. /// <param name="localPath"></param>
  304. /// <param name="remotePath"></param>
  305. /// <returns></returns>
  306. private string[] FiltCommonFiles(string localPath, string remotePath)
  307. {
  308. try
  309. {
  310. string[] Local = System.IO.Directory.GetFiles(localPath);
  311. for (int i = 0; i < Local.Length; i++)
  312. Local[i] = Local[i].Substring(Local[i].LastIndexOf("\\") + 1);
  313. string[] Remote = StartForm.myFtp.GetFileNameList(remotePath);
  314. for (int i = 0; i < Remote.Length; i++)
  315. Remote[i] = Remote[i].Substring(Remote[i].LastIndexOf("/") + 1);
  316. return Local.Intersect(Remote).ToList().ToArray();
  317. }
  318. catch (Exception ex)
  319. {
  320. throw new Exception("同步失败,原因: " + ex.Message);
  321. }
  322. }
  323. /// <summary>
  324. /// 同步本地和远端文件夹
  325. /// 本地有、远端无的文件夹,上传该目录下本地所有文件
  326. /// 本地有和远端有的文件夹,上传本地有但远端没有的文件
  327. /// </summary>
  328. /// <param name="PathName"></param>
  329. /// <returns></returns>
  330. private void PathSyncWithServer(string PathName)
  331. {
  332. List<string> pathResult = null;
  333. //获取本地和远端的目录差集
  334. pathResult = FiltDiffDirectory(UserPath + PathName, myServerCfg.RootPath + PathName).ToList();
  335. if (pathResult.Count != 0)
  336. {
  337. foreach (string path in pathResult)
  338. {
  339. //远端建立文件夹
  340. myFtp.MakeDir(myServerCfg.RootPath + PathName + "/" + path);
  341. //获取待上传文件列表
  342. string[] fileList = Directory.GetFiles(UserPath + PathName + "\\" + path);
  343. for (int i = 0; i < fileList.Length; i++)
  344. fileList[i] = fileList[i].Substring(fileList[i].LastIndexOf("\\") + 1);
  345. //上传文件
  346. if (fileList.Length != 0)
  347. {
  348. foreach (string file in fileList)
  349. {
  350. myFtp.UploadFile(UserPath + PathName + "\\" + path + "\\" + file, myServerCfg.RootPath + PathName + "/" + path);
  351. }
  352. }
  353. }
  354. }
  355. //获取本地和远端的目录交集
  356. pathResult = FiltCommonDirectory(UserPath + PathName, myServerCfg.RootPath + PathName).ToList();
  357. if (pathResult.Count != 0)
  358. {
  359. foreach (string path in pathResult)
  360. {
  361. //获取该目录本地和远端文件名的差集,本地有但远端无
  362. string[] fileList = FiltDiffFiles(UserPath + PathName + "\\" + path, myServerCfg.RootPath + PathName + "/" + path);
  363. //上传文件
  364. if (fileList.Length != 0)
  365. {
  366. foreach (string file in fileList)
  367. {
  368. myFtp.UploadFile(UserPath + PathName + "\\" + path + "\\" + file, myServerCfg.RootPath + PathName + "/" + path);
  369. }
  370. }
  371. }
  372. }
  373. }
  374. private void button_Import_Click(object sender, EventArgs e)
  375. {
  376. //不允许离线使用时检查网络
  377. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  378. {
  379. if (myFtp.IsNetConnected == false)
  380. {
  381. MessageBox.Show("请检查网络,或联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  382. return;
  383. }
  384. }
  385. //输入用户名
  386. EnterForm1.ShowDialog();
  387. try
  388. {
  389. if (EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//检验模式所有用户支持
  390. {
  391. CheckForm1.timer1.Enabled = false;
  392. if (EnterForm1.comboBox_User.Text == "武汉Wuhan") //武汉账户不使用本地文件,需要使用时采用工程账户登录
  393. ImportForm1.checkBox_LocalFile.Enabled = false;
  394. ImportForm1.ShowDialog();
  395. }
  396. else
  397. {
  398. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  399. }
  400. }
  401. catch (Exception)
  402. {
  403. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  404. }
  405. }
  406. private void button_Export_Click(object sender, EventArgs e)
  407. {
  408. //不允许离线使用时检查网络
  409. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  410. {
  411. if (myFtp.IsNetConnected == false)
  412. {
  413. MessageBox.Show("请检查网络,或联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  414. return;
  415. }
  416. }
  417. EnterForm1.ShowDialog();
  418. try
  419. {
  420. if(EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//生成参数模式仅用户PT
  421. {
  422. if (EnterForm1.comboBox_User.Text == "工程Engineer")
  423. {
  424. ExportForm1.ShowDialog();
  425. }
  426. else
  427. {
  428. MessageBox.Show("权限不支持", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  429. }
  430. }
  431. else
  432. {
  433. MessageBox.Show("密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  434. }
  435. }
  436. catch (Exception)
  437. {
  438. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  439. }
  440. }
  441. private void button_Mang_Click(object sender, EventArgs e)
  442. {
  443. EnterForm1.ShowDialog();
  444. try
  445. {
  446. if (EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//本地文件管理仅支持PT用户
  447. {
  448. if (EnterForm1.comboBox_User.Text == "工程Engineer")
  449. {
  450. ManageForm1.ShowDialog();
  451. }
  452. else
  453. {
  454. MessageBox.Show("权限不支持", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  455. }
  456. }
  457. else
  458. {
  459. MessageBox.Show("密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  460. }
  461. }
  462. catch (Exception)
  463. {
  464. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  465. }
  466. }
  467. private void button_Check_Click(object sender, EventArgs e)
  468. {
  469. //不允许离线使用时,检查网络
  470. if (myServerCfg.Local == "DISABLE")//不允许本地文件
  471. {
  472. if (myFtp.IsNetConnected == false)
  473. {
  474. MessageBox.Show("请检查网络,或联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  475. return;
  476. }
  477. }
  478. //输入用户名
  479. EnterForm1.ShowDialog();
  480. try
  481. {
  482. if (EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//所有用户支持
  483. {
  484. ImportForm1.timer1.Enabled = false;
  485. if (EnterForm1.comboBox_User.Text == "武汉Wuhan") //武汉账户不使用本地文件,需要使用时采用工程账户登录
  486. CheckForm1.checkBox_LocalFile.Enabled = false;
  487. CheckForm1.ShowDialog();
  488. }
  489. else
  490. {
  491. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  492. }
  493. }
  494. catch (Exception)
  495. {
  496. MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  497. }
  498. }
  499. private void StartForm_Load(object sender, EventArgs e)
  500. {
  501. }
  502. private void StartForm_FormClosing(object sender, FormClosingEventArgs e)
  503. {
  504. #if false
  505. //关闭前,删除本地所有配置文件
  506. string path = StartForm.UserPath + "\\cfg\\"; ;
  507. try
  508. {
  509. DirectoryInfo dir = new DirectoryInfo(path);
  510. FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
  511. foreach (FileSystemInfo i in fileinfo)
  512. {
  513. if (i is DirectoryInfo) //判断是否文件夹
  514. {
  515. DirectoryInfo subdir = new DirectoryInfo(i.FullName);
  516. subdir.Delete(true); //删除子目录和文件
  517. }
  518. else
  519. {
  520. File.Delete(i.FullName); //删除指定文件
  521. }
  522. }
  523. //MessageBox.Show("文件清理成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  524. }
  525. catch (Exception)
  526. {
  527. MessageBox.Show("文件清理失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  528. }
  529. #endif
  530. }
  531. }
  532. }