Clean up
This commit is contained in:
@ -9,9 +9,9 @@ namespace RageCoop.Core
|
||||
{
|
||||
public static void DownloadFile(string url, string destination, Action<int> progressCallback = null)
|
||||
{
|
||||
if (File.Exists(destination)) { File.Delete(destination); }
|
||||
AutoResetEvent ae = new AutoResetEvent(false);
|
||||
WebClient client = new WebClient();
|
||||
if (File.Exists(destination)) File.Delete(destination);
|
||||
var ae = new AutoResetEvent(false);
|
||||
var client = new WebClient();
|
||||
|
||||
// TLS only
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
@ -19,13 +19,11 @@ namespace RageCoop.Core
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
client.DownloadProgressChanged += (s, e1) => progressCallback?.Invoke(e1.ProgressPercentage);
|
||||
client.DownloadFileCompleted += (s, e2) =>
|
||||
{
|
||||
ae.Set();
|
||||
};
|
||||
client.DownloadFileCompleted += (s, e2) => { ae.Set(); };
|
||||
client.DownloadFileAsync(new Uri(url), destination);
|
||||
ae.WaitOne();
|
||||
}
|
||||
|
||||
public static string DownloadString(string url)
|
||||
{
|
||||
// TLS only
|
||||
@ -35,8 +33,8 @@ namespace RageCoop.Core
|
||||
SecurityProtocolType.Tls;
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
WebClient client = new WebClient();
|
||||
var client = new WebClient();
|
||||
return client.DownloadString(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user