Program.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !DEBUG
  2. using System;
  3. using System.IO;
  4. #endif
  5. using System;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. using Update.Config;
  10. using Update.Util;
  11. namespace Update
  12. {
  13. class Program
  14. {
  15. //入口
  16. static void Main(string[] args)
  17. {
  18. #if DEBUG
  19. ////测试用地址
  20. HostConfig.Init(FilePathUtil.GetAbsolutePath("Test\\" + HostConfig.DEFAULT_NAME));
  21. #else
  22. if (args == null || args.Length < 1) return;
  23. //Progrom Files格式的文件夹会被拆分成两个参数传进来,所以需要进行合并
  24. HostConfig.Init(String.Join(" ", args.Select(t => t.ToString())));//运行
  25. #endif
  26. try
  27. {
  28. Application.EnableVisualStyles();
  29. Application.SetCompatibleTextRenderingDefault(false);
  30. if (UpdateUtil.CheckUpdate())
  31. {
  32. //需要更新
  33. Application.Run(new FrmUpdate());
  34. }
  35. else
  36. {
  37. //不需要更新,直接启动
  38. ProcessUtil.Start(HostConfig.ExecutablePath, "Updater Start");
  39. }
  40. }
  41. catch (Exception e)
  42. {
  43. MessageBox.Show(e.StackTrace);
  44. }
  45. }
  46. }
  47. }