我有这个代码适用于一个文件下载。
如何为此代码添加多个要下载的文件?
private void Form1_Load(object sender, EventArgs e)
{
WebClient client = new WebClient();
client.DownloadProgressChanged += Client_DownloadProgressChanged;
client.DownloadFileCompleted += Client_DownloadFileCompleted;
client.DownloadFileAsync(new Uri("http://download.thinkbroadband.com/10MB.zip"), @"c:\folder\10MB.zip");
}
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("completed");
}
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Maximum = (int)e.TotalBytesToReceive / 100;
progressBar1.Value = (int)e.BytesReceived / 100;
}
答案 0 :(得分:0)
您可以创建多个进度条和多个Web客户端。每个WebClient
都应使用适当的进度条。