Beispiel #1
0
        public static async Task Main()
        {
            //string APIString = "https://rss.itunes.apple.com/api/v1/us/apple-music/hot-tracks/all/100/explicit.json";
            string APIString = "https://sample-videos.com/zip/10mb.zip";

            var downloadFileUrl = APIString;

            var documents           = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var destinationFilePath = Path.Combine(documents, "explicit.json");

            try
            {
                using (var client = new HttpClientDownloadWithProgress(downloadFileUrl, destinationFilePath))
                {
                    client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) => {
                        Console.WriteLine($"{progressPercentage}% ({totalBytesDownloaded}/{totalFileSize})");
                    };

                    await client.StartDownload();
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine("Exception - ");
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
        private async void Download()
        {
            if (DarkMessageBoxHelper.ShowOKCancel(string.Format(Properties.Resources.AboutToDownload, Header, InputGestureText), Properties.Resources.Warning, Properties.Resources.OK, Properties.Resources.Cancel) == MessageBoxResult.OK)
            {
                Stopwatch downloadTimer = Stopwatch.StartNew();
                StatusBarVm.statusBarViewModel.Set($"{Properties.Resources.Downloading} {Header}", Properties.Resources.Waiting);

                string path = $"{Properties.Settings.Default.OutputPath}//Backups//{Header}";
                using var client        = new HttpClientDownloadWithProgress(DownloadUrl, path);
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
                {
                    StatusBarVm.statusBarViewModel.Set($"{Properties.Resources.Downloading} {Header}   🠞   {progressPercentage}%", Properties.Resources.Waiting);
                };

                await client.StartDownload().ConfigureAwait(false);

                downloadTimer.Stop();
                if (new FileInfo(path).Length > 0)
                {
                    DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[CDN]", $"Downloaded {Header} in {downloadTimer.ElapsedMilliseconds} ms");
                    StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.DownloadSuccess, Header), Properties.Resources.Success);
                    Globals.gNotifier.ShowCustomMessage(Properties.Resources.Success, string.Format(Properties.Resources.DownloadSuccess, Header), "/FModel;component/Resources/check-circle.ico", path);
                }
                else
                {
                    File.Delete(path);
                    DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[CDN]", $"Error while downloading {Header}, spent {downloadTimer.ElapsedMilliseconds} ms");
                    StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.DownloadError, Header), Properties.Resources.Error);
                    Globals.gNotifier.ShowCustomMessage(Properties.Resources.Error, string.Format(Properties.Resources.DownloadError, Header), "/FModel;component/Resources/alert.ico");
                }
            }
        }
Beispiel #3
0
        // await HttpClientDownloadWithProgress.Test();
        public static async System.Threading.Tasks.Task Test()
        {
            string url = "https://speed.hetzner.de/100MB.bin";

            // url = "https://speed.hetzner.de/1GB.bin";
            // url = "https://speed.hetzner.de/10GB.bin";

            using (HttpClientDownloadWithProgress client = new HttpClientDownloadWithProgress(url, @"D:\foo.bin"))
            {
                // if(false)
                client.ProgressChanged +=
                    delegate(long?totalFileSize, long totalBytesDownloaded, double?progressPercentage)
                {
                    if (totalFileSize.HasValue)
                    {
                        System.Console.WriteLine("Total file size: {0}", totalFileSize.Value);
                    }

                    System.Console.WriteLine("Total byte downloaded: {0}", totalBytesDownloaded);

                    if (progressPercentage.HasValue)
                    {
                        System.Console.WriteLine("Progress: {0}%", progressPercentage.Value);
                    }
                }
                ;

                await client.StartDownload();
            } // End Using client
        }     // End Task Test
Beispiel #4
0
        public static void AddNewStatic(string id, string title, string content, string icon_url, string time, JArray days)
        {
            string  result = File.ReadAllText(DatabaseNotification);
            JArray  arr    = JArray.Parse(result);
            JObject o      = new JObject();

            o["id"]       = int.Parse(id);
            o["title"]    = title;
            o["content"]  = content;
            o["icon_url"] = icon_url;
            o["time"]     = time;
            o["days"]     = days;

            var downloadFileUrl     = icon_url.ToString();
            var destinationFilePath = DatabaseConstIconListFolder;
            Uri uri = new Uri(downloadFileUrl);

            destinationFilePath = destinationFilePath + Path.GetFileName(uri.LocalPath);
            using (var hcdp = new HttpClientDownloadWithProgress(downloadFileUrl, destinationFilePath))
            {
                hcdp.StartDownload().Wait();
            }
            o["local_icon_url"] = destinationFilePath;
            arr.Add(o);
            //File.WriteAllText(DatabaseConstIconListFolder, "[]");
            TextWriter tw = new StreamWriter(DatabaseNotification);

            tw.WriteLine(arr);
            tw.Close();
        }
Beispiel #5
0
        public void CanceledDownload()
        {
            IWebClient client    = new HttpClientWrapper();
            var        uri       = new Uri("http://releases.ubuntu.com/18.04.3/ubuntu-18.04.3-desktop-amd64.iso");
            var        cts       = new CancellationTokenSource(1500);
            string     directory = Path.Combine(TestOutputPath, "CanceledDownload");

            Directory.CreateDirectory(directory);
            string filePath = Path.Combine(directory, "CanceledDownload.iso");

            var progressDownload = new HttpClientDownloadWithProgress(client, uri, filePath);

            progressDownload.ProgressChanged += (long?totalFileSize, long totalBytesDownloaded, double?progressPercentage) =>
            {
                Console.WriteLine($"{totalBytesDownloaded}/{totalFileSize} : {progressPercentage}%");
            };

            try
            {
                progressDownload.StartDownload(cts.Token).Wait();
            }
            catch (AggregateException ex)
            {
                if (!(ex.InnerException is OperationCanceledException))
                {
                    Assert.Fail("Wrong exception thrown.");
                }
            }
            catch (Exception)
            {
                Assert.Fail("Wrong exception thrown.");
            }
        }
Beispiel #6
0
        public static async Task GetIconList()
        {
            //Debug.WriteLine("GetIconList: Start Get List");
            var values = new Dictionary <string, string>
            {
                { "secureToken", "fc712a198e2520b9f3773518a519e415asdtwe" },
            };

            using (var client = new HttpClient())
            {
                try
                {
                    var content  = new FormUrlEncodedContent(values);
                    var response = await client.PostAsync(Api_BaseUrl + Api_ListIcons, content);

                    Task <string> responseString = response.Content.ReadAsStringAsync();
                    string        outputJson     = await responseString;
                    var           SettingFile    = File.Create(DatabaseIconListFile);
                    SettingFile.Close();
                    JToken token      = JObject.Parse(outputJson);
                    int    error_code = (int)token["error_code"];
                    File.WriteAllText(DatabaseIconListFile, "[]");
                    if (error_code == 0)
                    {
                        TextWriter tw  = new StreamWriter(DatabaseIconListFile);
                        JArray     arr = new JArray();
                        foreach (var item in token["data"])
                        {
                            var downloadFileUrl     = item["icon_url"].ToString();
                            var destinationFilePath = DatabaseIconListFolder;
                            Uri uri = new Uri(downloadFileUrl);
                            destinationFilePath = destinationFilePath + Path.GetFileName(uri.LocalPath);
                            using (var hcdp = new HttpClientDownloadWithProgress(downloadFileUrl, destinationFilePath))
                            {
                                //hcdp.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
                                //{
                                //    //Debug.WriteLine($"{progressPercentage}% ({totalBytesDownloaded}/{totalFileSize})");
                                //};
                                await hcdp.StartDownload();
                            }
                            JObject o = new JObject();
                            o["web"]   = item["icon_url"];
                            o["local"] = destinationFilePath;
                            arr.Add(o);
                        }
                        tw.WriteLine(arr);
                        tw.Close();
                    }
                }
                catch (Exception)
                {
                    //ex.ToString();
                }
            }
            //Debug.WriteLine("GetIconList: End Get List");
        }
Beispiel #7
0
        public async Task RunUpdateAsync(RemoteUpdate remoteUpdate)
        {
            try
            {
                _logger.Log("run update: start", Category.Info, Priority.Low);
                IsUpdating           = true;
                UpdateProgressValue  = 0;
                UpdateProgressStatus = "";
                var destinationFilePath = Path.Combine(Path.GetTempPath(), remoteUpdate.Update.Installer.Name);;

                using var client        = new HttpClientDownloadWithProgress(remoteUpdate.Update.Installer.Uri, destinationFilePath);
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
                {
                    UpdateProgressValue  = (int)progressPercentage;
                    UpdateProgressStatus = $"Downloading update {progressPercentage}% ({totalBytesDownloaded}/{totalFileSize})";
                };
                _logger.Log($"start download: {remoteUpdate.Update.Installer.Uri}", Category.Info, Priority.Medium);
                await client.StartDownload();

                _logger.Log($"download completed: {remoteUpdate.Update.Installer.Uri}", Category.Info, Priority.Medium);

                if (!string.IsNullOrEmpty(destinationFilePath))
                {
                    if (File.Exists(destinationFilePath))
                    {
                        _logger.Log($"start installation of: {destinationFilePath}", Category.Info, Priority.Low);
                        UpdateProgressStatus = "Starting installation ...";
                        //automatic installation
                        const string arguments = "/qb /passive /norestart";
                        var          startInfo = new ProcessStartInfo(destinationFilePath)
                        {
                            Arguments       = arguments,
                            UseShellExecute = true
                        };
                        Process.Start(startInfo);
                        _logger.Log($"killing application", Category.Info, Priority.Low);
                        Process.GetCurrentProcess().Kill();
                    }
                    else
                    {
                        _logger.Log($"missing installation: {destinationFilePath}", Category.Warn, Priority.Medium);
                    }
                }
                IsUpdating = false;
                _logger.Log("run update: start", Category.Info, Priority.Low);
            }
            catch (Exception exception)
            {
                _logger.Log($"RunUpdateAsync {exception.Message}", Category.Exception, Priority.High);
            }
        }
Beispiel #8
0
        private async Task <(bool, string)> GetVsCode64Zip(ProgressBar progBar, CancellationToken token, string tmpDir)
        {
            var output = Path.Combine(tmpDir, config.VsCode64Name);

            using (var client = new HttpClientDownloadWithProgress(config.VsCode64Url, output))
            {
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) => {
                    if (progressPercentage != null)
                    {
                        progBar.Value = (int)progressPercentage;
                    }
                };

                return(await client.StartDownload(token), output);
            }
        }
        public static async Task DownloadUpdateAsync()
        {
            CheckAndClearTempDir();

            var downloadFileUrl     = UpdateExePath;
            var destinationFilePath = UpdateTempExe;

            using (var client = new HttpClientDownloadWithProgress(downloadFileUrl, destinationFilePath))
            {
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) => {
                    ProgressChanged?.Invoke(totalFileSize, totalBytesDownloaded, progressPercentage);
                };

                await client.StartDownload();
            }
        }
Beispiel #10
0
        public void TestDownloadMl()
        {
            var http = new HttpClientDownloadWithProgress("https://github.com/Nicolas-Constanty/Dnai.ML.PluginDependencies/releases/download/v1.0/Dnai.ML.PluginDependencies.zip",
                                                          @"C:\Users\Mentlegen\Desktop\Dnai.ML.PluginDependencies.zip");

            http.ProgressChanged += Http_ProgressChanged;
            Task.Run(async() =>
            {
                await http.StartDownload();
            }).Wait();

            //WebClient wc = new WebClient();
            //wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
            //wc.DownloadFileCompleted += Wc_DownloadFileCompleted;
            //wc.DownloadFileAsync(new Uri("https://github.com/Nicolas-Constanty/Dnai.ML.PluginDependencies/releases/download/v1.0/Dnai.ML.PluginDependencies.zip"), @"C:\Users\Mentlegen\Desktop\Dnai.ML.PluginDependencies.zip");
            //while (downloading) ;
        }
Beispiel #11
0
        /// <summary>
        /// Start downloading a file from the leg site.  Returns once the download is started.
        /// </summary>
        /// <param name="filename">Name of the file to be downloaded from the leg site.</param>
        /// <param name="form1">Need to update progressLegSite, so need the form.</param>
        private async Task <TimeSpan> DownloadLegSiteFileAsync(string filename, Form1 form1)
        {
            LogThis($"Downloading {filename}, which is the most recent zip file on the leg site.");
            var         leg_site_path = Path.Combine(Config.Instance.LegSite, filename);
            var         output_path   = OutputPath(filename); // Throw if output file cannot be created.
            ProgressBar progress      = form1.progressLegSite;
            var         start_time    = DateTime.Now;

            using (var client = new HttpClientDownloadWithProgress(leg_site_path, output_path)) {
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) => {
                    LogThis($"{progressPercentage} % ({totalBytesDownloaded}/{totalFileSize})");
                    //progress.Invoke(new Action(() => progress.Value = Convert.ToInt32(progressPercentage)));
                };
                await client.StartDownload();
            }
            var interval = DateTime.Now - start_time;

            return(interval);
        }
Beispiel #12
0
        /// <summary>
        /// Async Task to download a file.
        /// </summary>
        /// <param name="id">Id of the tool to download</param>
        /// <returns></returns>
        private async Task Download(int id)
        {
            string downloadLink = repositories[id].latestVersionLink, fileName;
            string extension = System.IO.Path.GetExtension(downloadLink);

            fileName = repositories[id].App + extension;

            using (var client = new HttpClientDownloadWithProgress(downloadLink, fileName))
            {
                client.ProgressChanged += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        dispControls[id].DownloadPercent = Convert.ToDouble(progressPercentage);
                    }));
                };

                client.DownloadCompleted += () =>
                {
                    try
                    {
                        Unzip(id, extension);
                        Settings.Default.ToolSettings[id].Downloaded     = true; // = new ToolSettings { Downloaded = true };
                        Settings.Default.ToolSettings[id].CurrentVersion = Settings.Default.ToolSettings[id].LatestVersion;
                        Settings.Default.Save();
                        dispControls[id].ApplicationVersion = Settings.Default.ToolSettings[id].CurrentVersion;
                        Dispatcher.Invoke(new Action(() =>
                        {
                            dispControls[id].IsDownloaded = true;
                            dispControls[id].ForceCheckEnableSwitch(true);
                        }));
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error while extracting the downloaded file.");
                    }
                };

                await client.StartDownload();
            }
        }
        private async Task <bool> TryDownloadNewLauncher(string downloadTargetPath)
        {
            var downloadLauncherUrl = Constants.GetLauncherFileDownloadUrl(_settingsProvider.GetCurrentSettings().UpdateChannel);

            _logger.Write("Downloading new launcher.");

            try
            {
                using (var httpClientWithProgress = new HttpClientDownloadWithProgress(downloadLauncherUrl, downloadTargetPath))
                {
                    httpClientWithProgress.ProgressChanged += (size, downloaded, percentage) => UpdateStatusChanged?.Invoke(percentage ?? 50);
                    await httpClientWithProgress.StartDownload();
                }

                return(true);
            }
            catch (Exception e)
            {
                _logger.Write(e);
            }

            return(false);
        }
        private async Task <bool> DownloadNewClientFiles()
        {
            var updateFilePath = GetUpdateDownloadPath();

            FileOperationsHelper.EnsureFileDirectory(updateFilePath);

            var downloadUpdateUrl = Constants.GetUpdateFileDownloadUrl(_settingsProvider.GetCurrentSettings().UpdateChannel);

            using (var client = new HttpClientDownloadWithProgress(downloadUpdateUrl, updateFilePath))
            {
                //client.ProgressChanged += (size, downloaded, percentage) =>
                //	_splashScreenProgressProvider.UpdateStep(LaunchStep.DownloadNewClient, LaunchStepStatus.Processing, percentage);

                await client.StartDownload();
            }

            if (File.Exists(updateFilePath))
            {
                return(await ExtractUpdate(updateFilePath));
            }

            _notificationService.ShowNotification("Failed to download update.", true);
            return(false);
        }
Beispiel #15
0
            public static async Task <bool> CheckForUpdates()
            {
#if DEBUG
                File.WriteAllText("../../../Installer/latest.json",
                                  JsonSerializer.Serialize(SerializableVersion.GetAppVersion())
                                  );
#endif
                if (Config.AppWasUpdated)
                {
                    Log.Information("Application was updated last time it ran, cleaning up.");
                    if (File.Exists("./PingLogger-old.exe"))
                    {
                        File.Delete("./PingLogger-old.exe");
                    }
                    if (Config.LastTempDir != string.Empty && Directory.Exists(Config.LastTempDir))
                    {
                        File.Delete(Config.LastTempDir + "/PingLogger.Setup.exe");
                        Directory.Delete(Config.LastTempDir);
                        Config.LastTempDir = string.Empty;
                    }
                    Config.AppWasUpdated = false;
                }
                else
                {
                    if (Config.UpdateLastChecked.Date >= DateTime.Today)
                    {
                        Log.Information("Application already checked for update today, skipping.");
                        return(true);
                    }
                    SplashScreenViewModel = new ViewModels.SplashScreenViewModel();
                    SplashScreen          = new Views.SplashScreen()
                    {
                        DataContext = SplashScreenViewModel
                    };
                    SplashScreen.Show();
                    SplashScreenViewModel.ProgressBarIndeterminate = true;
                    var localVersion = Assembly.GetExecutingAssembly().GetName().Version;

                    try
                    {
                        var  httpClient       = new WebClient();
                        bool downloadComplete = false;
                        httpClient.DownloadFileCompleted += (_, _) => { downloadComplete = true; };

                        string serverUrl = "https://pinglogger.lexdysia.com/";

                        await httpClient.DownloadFileTaskAsync($"{serverUrl}/latest.json", "./latest.json");

                        while (!downloadComplete)
                        {
                            await Task.Delay(100);
                        }
                        var latestJson = await File.ReadAllTextAsync("./latest.json");

                        var remoteVersion = JsonSerializer.Deserialize <SerializableVersion>(latestJson);
                        File.Delete("./latest.json");

                        Log.Information($"Remote version is {remoteVersion}, currently running {localVersion}");
                        if (remoteVersion > localVersion)
                        {
                            Log.Information("Remote contains a newer version");
                            if (true)
                            {
                                if (Config.IsInstalled)
                                {
                                    Config.LastTempDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Temp\\{RandomString(8)}";
                                    Directory.CreateDirectory(Config.LastTempDir);
                                    Log.Information($"Creating temporary path {Config.LastTempDir}");
                                    Log.Information($"Downloading newest installer to {Config.LastTempDir}\\PingLogger-Setup.msi");

                                    if (remoteVersion is not null)
                                    {
                                        var downloadURL = $"{serverUrl}/{remoteVersion.Major}{remoteVersion.Minor}{remoteVersion.Build}/win/install/PingLogger.Setup.exe";
                                        Log.Information($"Downloading from {downloadURL}");
                                        using var downloader = new HttpClientDownloadWithProgress(downloadURL, Config.LastTempDir + "\\PingLogger.Setup.exe");
                                        SplashScreenViewModel.UpdateMessage = $"Downloading PingLogger setup v{remoteVersion}";
                                        downloader.ProgressChanged         += Downloader_ProgressChanged;
                                        await downloader.StartDownload();
                                    }

                                    Config.AppWasUpdated = true;
                                    Log.Information("Uninstalling current version.");
                                    Process.Start(new ProcessStartInfo
                                    {
                                        FileName        = $"{Config.LastTempDir}/PingLogger.Setup.exe",
                                        UseShellExecute = true,
                                        Arguments       = "/SILENT /CLOSEAPPLICATIONS"
                                    });

                                    Log.Information("Installer started, closing.");
                                    Environment.Exit(0);
                                }
                                else
                                {
                                    Log.Information("Renamed PingLogger.exe to PingLogger-old.exe");
                                    File.Move("./PingLogger.exe", "./PingLogger-old.exe");
                                    Log.Information("Downloading new PingLogger.exe");

                                    if (remoteVersion is not null)
                                    {
                                        string[] fileList = { "libHarfBuzzSharp.dll", "libSkiaSharp.dll", "PingLogger.exe" };
                                        SplashScreenViewModel.UpdateMessage = $"Downloading PingLogger v{remoteVersion}";
                                        foreach (var file in fileList)
                                        {
                                            var downloadUrl = $"{serverUrl}{remoteVersion.Major}{remoteVersion.Minor}{remoteVersion.Build}/win/sf/{file}";
                                            Log.Information($"Downloading from {downloadUrl}");
                                            using var downloader        = new HttpClientDownloadWithProgress(downloadUrl, $"./{file}");
                                            downloader.ProgressChanged += Downloader_ProgressChanged;
                                            await downloader.StartDownload();
                                        }
                                    }

                                    Config.AppWasUpdated = true;

                                    Process.Start(new ProcessStartInfo
                                    {
                                        FileName = "./PingLogger.exe"
                                    });

                                    Log.Information("Starting new version of PingLogger");
                                    Environment.Exit(0);
                                }
                            }
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        Log.Error("Unable to auto update: " + ex.Message);
                        return(true);
                    }
                }
                Config.UpdateLastChecked = DateTime.Now;
                CloseSplashScreen();
                return(true);
            }
Beispiel #16
0
        public static async Task CheckForUpdates()
        {
            if (Config.AppWasUpdated)
            {
                Logger.Info("Application was updated last time it ran, cleaning up.");
                if (File.Exists("./PingLogger-old.exe"))
                {
                    File.Delete("./PingLogger-old.exe");
                }
                if (Config.LastTempDir != string.Empty && Directory.Exists(Config.LastTempDir))
                {
                    File.Delete(Config.LastTempDir + "/PingLogger-Setup.msi");
                    Directory.Delete(Config.LastTempDir);
                    Config.LastTempDir = string.Empty;
                }
                Config.AppWasUpdated = false;
            }
            else
            {
                if (Config.UpdateLastChecked.Date >= DateTime.Today)
                {
                    Logger.Info("Application already checked for update today, skipping.");
                    return;
                }
                splashScreen = new Controls.SplashScreen();
                splashScreen.Show();
                splashScreen.dlProgress.IsIndeterminate = true;
                splashScreen.dlProgress.Value           = 1;
                var localVersion = Assembly.GetExecutingAssembly().GetName().Version;

                try
                {
                    var  httpClient       = new WebClient();
                    bool downloadComplete = false;
                    httpClient.DownloadFileCompleted += (o, i) => { downloadComplete = true; };

                    string azureURL = "https://pingloggerfiles.blob.core.windows.net/";

                    await httpClient.DownloadFileTaskAsync($"{azureURL}version/latest.json", $"./latest.json");

                    while (!downloadComplete)
                    {
                        await Task.Delay(100);
                    }
                    var latestJson    = File.ReadAllText("./latest.json");
                    var remoteVersion = JsonSerializer.Deserialize <SerializableVersion>(latestJson);
                    File.Delete("./latest.json");

                    Logger.Info($"Remote version is {remoteVersion}, currently running {localVersion}");
                    if (remoteVersion > localVersion)
                    {
                        Logger.Info("Remote contains a newer version");
                        if (Controls.UpdatePromptDialog.Show())
                        {
                            if (Config.IsInstalled)
                            {
                                Config.LastTempDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Temp\\{RandomString(8)}";
                                Directory.CreateDirectory(Config.LastTempDir);
                                Logger.Info($"Creating temporary path {Config.LastTempDir}");
                                Logger.Info($"Downloading newest installer to {Config.LastTempDir}\\PingLogger-Setup.msi");
                                var downloadURL = $"{azureURL}v{remoteVersion.Major}{remoteVersion.Minor}{remoteVersion.Build}/PingLogger-Setup.msi";
                                Logger.Info($"Downloading from {downloadURL}");
                                using var downloader        = new HttpClientDownloadWithProgress(downloadURL, Config.LastTempDir + "\\PingLogger-Setup.msi");
                                splashScreen.mainLabel.Text = $"Downloading PingLogger setup v{remoteVersion}";
                                downloader.ProgressChanged += Downloader_ProgressChanged;
                                await downloader.StartDownload();

                                Config.AppWasUpdated = true;
                                Logger.Info("Uninstalling current version.");
                                string batchFile = $@"@echo off
msiexec.exe /q /l* '{ AppContext.BaseDirectory}Logs\Installer - v{localVersion}.log' /x {Config.InstallerGUID}
msiexec.exe /l* '{ AppContext.BaseDirectory}Logs\Installer - v{remoteVersion}.log' /i {Config.LastTempDir}/PingLogger-Setup.msi";
                                File.WriteAllText(Config.LastTempDir + "/install.bat", batchFile);
                                Process.Start(new ProcessStartInfo
                                {
                                    FileName        = "cmd.exe",
                                    UseShellExecute = true,
                                    Arguments       = $"{Config.LastTempDir}/install.bat"
                                });

                                Logger.Info("Installer started, closing.");
                                Environment.Exit(0);
                            }
                            else
                            {
                                Logger.Info("Renamed PingLogger.exe to PingLogger-old.exe");
                                File.Move("./PingLogger.exe", "./PingLogger-old.exe");
                                Logger.Info("Downloading new PingLogger.exe");
                                var downloadURL = $"{azureURL}v{remoteVersion.Major}{remoteVersion.Minor}{remoteVersion.Build}/PingLogger.exe";
                                Logger.Info($"Downloading from {downloadURL}");
                                using var downloader        = new HttpClientDownloadWithProgress(downloadURL, "./PingLogger.exe");
                                splashScreen.mainLabel.Text = $"Downloading PingLogger v{remoteVersion}";
                                downloader.ProgressChanged += Downloader_ProgressChanged;
                                await downloader.StartDownload();

                                Config.AppWasUpdated = true;

                                Process.Start(new ProcessStartInfo
                                {
                                    FileName = "./PingLogger.exe"
                                });

                                Logger.Info("Starting new version of PingLogger");
                                Environment.Exit(0);
                            }
                        }
                    }
                }
                catch (HttpRequestException ex)
                {
                    Logger.Error("Unable to auto update: " + ex.Message);
                    return;
                }
            }
            Config.UpdateLastChecked = DateTime.Now;
            return;
        }