I have an array of file names which I want to download.
The array is currently contained in a string[] and it is working inside of a BackgroundWorker.
What I want to do is use that array to download files and output the result into a progress bar which will tell me how long I have left for completion.
Is there a way I can do this.
Thanks.
Use WebClient to download files, there’s a method called “DownloadFile”.
Pseudo code
That’s the Easy part! Now, you need to know that when you are using a BackgroundWorker, you are no longer on the GUI-thread, which means that you Cannot update the ProgressBar without using a Delegate! Check this out: “Progress Bar Delegate“.
For .NET 4.0
You might want to parallelize the downloads! You can do this easily with .NET 4.0 by looking in to Tasks, check this blog about Paralell Programming. Otherwise you will, as another poster said have all IO on 1 thread, which may be not so optimized.