Example #1
0
        public static void DownloadUpdate()
        {
            try {
                GitHubReleaseAsset asset = AppContext.Instance.ReleaseInfo.assets[0];

                Uri    uri  = new Uri(asset.browser_download_url);
                string name = asset.name;

                WebClient.DownloadFileCompleted   += WebClient_OnDownloadFileCompleted;
                WebClient.DownloadProgressChanged += WebClient_OnDownloadProgressChanged;
                WebClient.DownloadFileAsync(uri, name);
            }
            catch (Exception) {
                Environment.Exit(0);
            }
        }
Example #2
0
        private static void ExtractUpdate()
        {
            GitHubReleaseAsset asset = AppContext.Instance.ReleaseInfo.assets[0];
            string             name  = asset.name;

            using ZipFile zipFile = ZipFile.Read(name);
            foreach (ZipEntry entry in zipFile)
            {
                try {
                    if (File.Exists("BootstrappedWPF.exe.nlog") && entry.FileName.Contains("BootstrappedWPF.exe.nlog"))
                    {
                        continue;
                    }

                    entry.Extract(Directory.GetCurrentDirectory(), ExtractExistingFileAction.OverwriteSilently);
                }
                catch (Exception) {
                    // IGNORED
                }
            }

            WebClient.Dispose();

            try {
                Process process = new Process {
                    StartInfo =
                    {
                        FileName = "BootstrappedWPF.exe",
                    },
                };
                process.Start();
            }
            catch (Exception) {
                // IGNORED
            }
            finally {
                WebClient.DownloadFileCompleted   -= WebClient_OnDownloadFileCompleted;
                WebClient.DownloadProgressChanged -= WebClient_OnDownloadProgressChanged;

                Environment.Exit(0);
            }
        }