/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fFileDownload_Load(object sender, EventArgs e) { using (CustomWebClient wc = new CustomWebClient()) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Use SecurityProtocolType.Ssl3 if needed for compatibility reasons wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); wc.UseDefaultCredentials = true; wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadStringCompleted += Wc_DownloadStringCompleted; wc.DownloadStringAsync(new Uri(uri)); } }
/// <summary> /// /// </summary> void LoadNextFile() { if (currentFile < uris.Length) { if (uris[currentFile].Length == 0) { currentFile++; LoadNextFile(); return; } } else { Close(); } progressBar1.Value = 0; progressBar2.Value = currentFile; if (currentFile < fileNames.Length) { label1.Text = labels[currentFile]; if (uris[currentFile].Length > 0) { if (fileNames[currentFile].Length > 0) { using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadFileCompleted += Wc_DownloadFileCompleted; wc.DownloadFileAsync(new Uri(uris[currentFile]), fileNames[currentFile]); } } else { using (CustomWebClient wc = new CustomWebClient()) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Use SecurityProtocolType.Ssl3 if needed for compatibility reasons wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); wc.UseDefaultCredentials = true; wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadStringCompleted += Wc_DownloadStringCompleted; wc.DownloadStringAsync(new Uri(uris[currentFile])); } } } currentFile++; } }