VersionTool.cs 832 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. namespace Azylee.Core.VersionUtils
  7. {
  8. public class VersionTool
  9. {
  10. public static Version Format(string s)
  11. {
  12. //解析最新版本号
  13. Version version = null;
  14. try
  15. {
  16. version = new Version(s);
  17. }
  18. catch (Exception e) { }
  19. return version;
  20. }
  21. public static Version GetVersion(string appFile)
  22. {
  23. try
  24. {
  25. FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(appFile);
  26. return Format(fileVersionInfo.FileVersion);
  27. }
  28. catch
  29. {
  30. return null;
  31. }
  32. }
  33. }
  34. }