I have a small app that downloads some files from a remote (HTTP) server to the users local hard drive, some of the files are large, but I don't know just how large at run time. Is there any method that will allow me download a file with some type of progress meter?
This is a WinForms app, right now I'm using WebClient.DownloadFile() to download the file.
Edit:
I've looked into the DownloadProgressChanged and OnDownloadProgressChanged events and they seem to work fine, but they will not work for my solution. I am downloading several files and if I use WebClient.DownloadFileAsync then the event is called several times/second because each file calls it.
Here is the basic structure of the app:
I don't mind downloading each file seperatly but without downloading them with DownloadFileAsync() I cannot use the event handlers.
Use WebClient.OnDownloadProgressChanged. Keep in mind, it's only possible to calculate progress if the server reports the size up front.
EDIT:
Looking at your update, what you can try is making a queue of URLs. Then, when a file finishes downloading (DownloadDataCompleted event), you will launch the async download of the next URL in the queue. I haven't tested this.
Handle the WebClient DownloadProgressChanged event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With