-
Notifications
You must be signed in to change notification settings - Fork 0
/
Download.cs
41 lines (37 loc) · 1.28 KB
/
Download.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
namespace UpdateManager
{
public class Download
{
public static void DownloadUpdates(string urlDownload, string path, AsyncCompletedEventHandler WebDownloadFileCompleted, DownloadProgressChangedEventHandler WebDownloadProgressChanged)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebClient webclient = new WebClient();
WebRequest.DefaultWebProxy = null;
webclient.Proxy = null;
webclient.DownloadFileCompleted += WebDownloadFileCompleted;
webclient.DownloadProgressChanged += WebDownloadProgressChanged;
webclient.DownloadFileAsync(new Uri(urlDownload), path);
}
public static void DirectDownload(string urlDefultDownload, string urlDownload)
{
try
{
if (string.IsNullOrWhiteSpace(urlDownload))
{
urlDownload = urlDefultDownload;
}
Process pr = new Process();
pr.StartInfo.FileName = urlDownload;
pr.Start();
}
catch (Exception)
{
throw;
}
}
}
}