예제 #1
0
        private void DownloadNewVersion()
        {
            TaskbarHelper.SetTaskbarProgress(0, 100);
            SetStatus($"Downloading version {Version}");
            InstallerPath = Path.Combine(DownloadPath, $"YT.Music.Uploader.v{Version}.Installer-{Platform}.msi");

            if (File.Exists(InstallerPath))
            {
                if (new FileInfo(InstallerPath).Length > 70000000)
                {
                    TaskbarHelper.SetTaskbarProgress(100, 100);
                    return;
                }
                else
                {
                    File.Delete(InstallerPath);
                }
            }

            if (!Directory.Exists(DownloadPath))
            {
                Directory.CreateDirectory(DownloadPath);
            }

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            using (var wc = new WebClient())
            {
                wc.DownloadProgressChanged += DownloadProgress;
                wc.DownloadFileCompleted   += DownloadComplete;
                wc.DownloadFileAsync(
                    new Uri(DownloadUrl),
                    InstallerPath
                    );
            }

            while (!_downloadComplete)
            {
                Thread.Sleep(200);
            }
        }
예제 #2
0
 private void DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
 {
     TaskbarHelper.SetTaskbarProgress(e.ProgressPercentage, 100);
     SetStatus($"Downloading version {Version} ({e.ProgressPercentage}%)");
 }