private int DownloadBd(string installationPath) { var channel = $"https://github.com/{repo}/BetterDiscordApp/archive/{branch}.zip"; var dest = $"{installationPath}\\resources\\BetterDiscord.zip"; Append("Downloading BandagedBD package"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; using (var wc = new TimedWebClient()) { wc.DownloadProgressChanged += (sender, args) => { setProgress(args.ProgressPercentage / 2); }; Append($"Using channel: {channel}"); Append($"Downloading to: {dest}"); try { wc.DownloadFile(channel, dest); } catch (WebException e) { Append("Download error: " + e.Message); return(0); } } Append("Finished downloading BandagedBD package"); return(ExtractBd(dest, $"{installationPath}\\resources")); }
private string DownloadFileFromCache(Uri uri, string destinationpath) { if (IsFileExpired(destinationpath, this.DefaultTTL)) { using (var w = new TimedWebClient(this.Timeout)) { w.CachePolicy = this.CachePolicy; w.Credentials = this.Credentials; w.Proxy = this.Proxy; w.Headers.Add(HttpRequestHeader.UserAgent, USERAGENT); w.DownloadFile(uri, destinationpath); } } return(destinationpath); }
private string DownloadFileFromCache(Uri uri, string destinationpath) { if (IsFileExpired(destinationpath, this.DefaultTTL)) { using (var w = new TimedWebClient(this.Timeout)) { w.CachePolicy = this.CachePolicy; w.Credentials = this.Credentials; w.Proxy = this.Proxy; w.Headers.Add(HttpRequestHeader.UserAgent, USERAGENT); w.DownloadFile(uri, destinationpath); } } return destinationpath; }