Jay
Jay

Reputation: 23

Display ProgessBar when downloading with WebClient in C#

I am using this code to download multiple file. My problem is that it downloads them all at one time and what I want to do is have the progress bar show each file downloaded to 100% then go to the next file. I mean I want the first file to download and go to 100% in progress bar then the second one and start the progress bar again till 100% and so on. But in my code it just has one progressbar that shows the progress for all files being downloaded at once. How can I do this?

WebClient webClient = new WebClient();

webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);

webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); //Progress Bar Handler

webClient.DownloadFileAsync(new Uri("http://www.somesite.com/Update/Updates.zip.001"), @"Updates.zip.001");
webClient.DownloadFileAsync(new Uri("http://www.somesite.com/Update/Updates.zip.002"), @"Updates.zip.002");

Upvotes: 1

Views: 1312

Answers (1)

SLaks
SLaks

Reputation: 887195

You can start downloading the second file in the Completed handler for the first file.

However, you should stick with your current behavior; it's better to download both files at once.

Upvotes: 1

Related Questions