From f0dbb6b22c4683c27b888ee9eb9e37a86e362323 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:19:03 +0800 Subject: [PATCH] Bug fix --- v2rayN/ServiceLib/Common/Utils.cs | 18 ++++++++++++++++-- v2rayN/ServiceLib/Handler/UpdateHandler.cs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) 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;