我必须下载3个7-Zip.exe文件,显示下载百分比。我根据此article创建了一个方法,但是没有发生“ DownloadProgressInProgress”和“ DownloadFileComplete”事件。
static void Main(string[] args)
{
string[] listUri = { "https://www.7-zip.org/a/7z1900.exe", "https://www.7-zip.org/a/7z1900.exe", "https://www.7-zip.org/a/7z1900.exe" };
for (int a = 0; a < listUri.Length; a++)
{
WebClient myWebClient = new WebClient();
myWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileComplete);
myWebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressInProgress);
myWebClient.DownloadFileAsync(new Uri(listUri[a]), @"C:\\Users\\Luca\\Desktop\\DownloadZip" + (a + 1).ToString() + ".exe");
}
}
private static void DownloadProgressInProgress(object sender, DownloadProgressChangedEventArgs e)
{
throw new NotImplementedException();
}
private static void DownloadFileComplete(object sender, AsyncCompletedEventArgs e)
{
throw new NotImplementedException();
}
如何通过下载文件列表来使用这两个事件?
谢谢!