From 2c1ef5bc612073ea80ec0e57e87838aaa2a9a7ec Mon Sep 17 00:00:00 2001 From: Joakim Skoglund Date: Sun, 18 Feb 2024 02:26:27 +0100 Subject: [PATCH] correct path --- UpdateHandler.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/UpdateHandler.cs b/UpdateHandler.cs index 822a832..865498a 100644 --- a/UpdateHandler.cs +++ b/UpdateHandler.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Net.WebRequestMethods; #endregion Using statements @@ -16,7 +17,7 @@ internal sealed class UpdateHandler { #region Private constants - private static readonly string VERSION_CHECK_BASE_URL = "http://github.com/voltura/weeknumber/releases/latest/download/"; + private static readonly string VERSION_CHECK_BASE_URL = "https://github.com/voltura/WeekNumber/releases/latest/download/"; private static readonly string VERSION_CHECK_URL = $"{VERSION_CHECK_BASE_URL}VERSION.TXT"; internal static readonly string APPLICATION_URL = "https://voltura.github.io/WeekNumber/"; @@ -119,14 +120,14 @@ internal void PerformUpdateCheck(bool silent = false) } try { - if (File.Exists(destinationFullPath) && - File.Exists(destinationFullPath + ".MD5")) + if (System.IO.File.Exists(destinationFullPath) && + System.IO.File.Exists(destinationFullPath + ".MD5")) { //remove smartscreen filter (alternative data stream Zone.Identifier) on downloaded installer executable file UnblockFile(destinationFullPath); //validate installer checksum string installerMD5 = CalculateMD5(destinationFullPath); - string installerInternetMD5 = File.ReadAllText(destinationFullPath + ".MD5").PadRight(32).Substring(0, 32); + string installerInternetMD5 = System.IO.File.ReadAllText(destinationFullPath + ".MD5").PadRight(32).Substring(0, 32); if (installerMD5 != installerInternetMD5) { LogAndShow($@"{Resources.FailedAutoInstall} @@ -235,7 +236,7 @@ private VersionInfo GetInternetVersion(bool silent) { // The URI formed by combining System.Net.WebClient.BaseAddress and address is invalid.-or- // An error occurred while downloading the resource. - LogAndShow($@"{Resources.FailedToPerformVersionCheck} + LogAndShow($@"{Resources.FailedToPerformVersionCheck} {Resources.CheckBrowserNavigation} {VERSION_CHECK_BASE_URL}", silent, we); @@ -292,9 +293,9 @@ private bool DownloadFile(string source, string destination) Log.LogCaller(); try { - if (File.Exists(destination)) File.Delete(destination); + if (System.IO.File.Exists(destination)) System.IO.File.Delete(destination); Task.Run(async () => { await new WebClient().DownloadFileTaskAsync(new Uri(source), destination); }).Wait(); - return File.Exists(destination); + return System.IO.File.Exists(destination); } catch (Exception ex) { @@ -360,11 +361,11 @@ private static string CalculateMD5(string filename) string fileMD5Hash = string.Empty; try { - if (File.Exists(filename)) + if (System.IO.File.Exists(filename)) { using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) { - using (FileStream stream = File.OpenRead(filename)) + using (FileStream stream = System.IO.File.OpenRead(filename)) { byte[] hash = md5.ComputeHash(stream); fileMD5Hash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); @@ -385,7 +386,7 @@ private static string CalculateMD5(string filename) } /// - /// Removes Zone Identification tagging that are using Alternate Data Streams (Zone.Identifier) created on file + /// Removes Zone Identification tagging that are using Alternate Data Streams (Zone.Identifier) created on file /// when downloaded from internet, also called 'Mark of the Web' /// Allows to execute file without Microsoft Defender SmartScreen interferance. /// See https://www.winhelponline.com/blog/bulk-unblock-files-downloaded-internet/ for more info @@ -398,7 +399,7 @@ private static bool UnblockFile(string fullPath) string parameters = @"-Command ""& {Unblock-File -Path """ + fullPath + @""" }"""; try { - if (!File.Exists(fullPath)) + if (!System.IO.File.Exists(fullPath)) { Log.ErrorString = $"File '{fullPath}' not found."; return result;