Monitor progress on .DownloadFile?

shawne

Well-known member
Joined
Feb 22, 2006
Messages
103
Location
Pennsylvania
Programming Experience
10+
Is there a simple way to create a progress bar to show download progress from a webclient.downloadfile? I have an app. that downloads multiple files and updates total progress as it completes each file and I also showed an animated GIF to give the user the appearance that it was actually doing something and not locked up. But it might be nice to have a progress for individual files and it's something i'd like to know even outside of this simple application. If there is no simple way of doing it, then i'll just forget about it.
 
If you use the OpenRead method of WebClient it will return a Stream that you can read bytes from (one by one or small chunks), with a FileStream you write these as you go to the file. Client.ResponseHeaders(Net.HttpResponseHeader.ContentLength) will return the total number of bytes of the requested file, so you can keep track of the progress in relation to how many bytes is read. There's a simple example in post 3 of this thread, though ContentLength is actually a Long data type.
 
Also My.Computer.Network.DownloadFile method has a few overloads where you can set ShowUI that displays progress (and allows user to cancel), with only one line of code it is the easiest option when you don't need more.
 
Back
Top