Hello,
I am trying to implement an Asynchronous file download from a web server using
private void btnDownload_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("test", "test");
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("ftp://2.1.1.1:17865/zaz.txt"), @"c:\myfile.txt");
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Download completed!");
}
Now the download works fine, what I would like to know is the following: assuming that I will have more than 1 download at a time, what is the best way to keep track of each download and report progress separately ? I was looking for a tag property of the WebClient, but could not find one.
Thank you