VersionTool.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //************************************************************************
  2. // author: yuzhengyang
  3. // date: 2018.3.27 - 2018.6.3
  4. // desc: 工具描述
  5. // Copyright (c) yuzhengyang. All rights reserved.
  6. //************************************************************************
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. namespace Azylee.Core.VersionUtils
  13. {
  14. public class VersionTool
  15. {
  16. public static Version Format(string s)
  17. {
  18. //解析最新版本号
  19. Version version = null;
  20. try
  21. {
  22. version = new Version(s);
  23. }
  24. catch (Exception e) { }
  25. return version;
  26. }
  27. public static Version GetVersion(string appFile)
  28. {
  29. try
  30. {
  31. FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(appFile);
  32. return Format(fileVersionInfo.FileVersion);
  33. }
  34. catch
  35. {
  36. return null;
  37. }
  38. }
  39. }
  40. }