diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 463e6f4b..ec161ced 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -572,14 +572,14 @@ namespace ServiceLib.Common { return string.Format("{0} - V{1} - {2}", Global.AppName, - FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString(), + GetVersionInfo(), File.GetLastWriteTime(location).ToString("yyyy/MM/dd")); } else { return string.Format("{0}/{1}", Global.AppName, - FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString()); + GetVersionInfo()); } } catch (Exception ex) @@ -589,6 +589,20 @@ namespace ServiceLib.Common } } + public static string GetVersionInfo() + { + try + { + string location = GetExePath(); + return FileVersionInfo.GetVersionInfo(location)?.FileVersion ?? "0.0"; + } + catch (Exception ex) + { + Logging.SaveLog(ex.Message, ex); + return "0.0"; + } + } + /// /// 取得GUID /// diff --git a/v2rayN/ServiceLib/Handler/UpdateHandler.cs b/v2rayN/ServiceLib/Handler/UpdateHandler.cs index b50f2cbd..96b35ac6 100644 --- a/v2rayN/ServiceLib/Handler/UpdateHandler.cs +++ b/v2rayN/ServiceLib/Handler/UpdateHandler.cs @@ -418,7 +418,7 @@ namespace ServiceLib.Handler } case ECoreType.v2rayN: { - curVersion = new SemanticVersion(FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString()); + curVersion = new SemanticVersion(Utils.GetVersionInfo()); message = string.Format(ResUI.IsLatestN, type, curVersion); url = string.Format(GetUrlFromCore(coreInfo), version); break;