How do I show download progress?

J

John Galt

I would like to be able to show progress in an FTP download. I can determine
the file size but am unclear on how to show percent complete in a progress
bar.

I'm guessing I will need to spawn a separate thread for this?

Does anyone know how this might be done?
 
B

Bob Powell [MVP]

Download your file from the server in smaller chunks of say 4096 bytes and
update a progress bar with the perecentage using the formula 100 / filesize
* currentAmountDownloaded

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 
J

John Galt

This sounds like a good idea, but I'm not sure how I can do this with my FTP
client.

Actually, if I could pull this off it would solve my next problem on how to
restart due to the fact that the download will often be over unreliable
wireless networks that come and go with the vagories of cell towers.
 
B

Bob Powell [MVP]

Ahh, what you didn't specify in your original post was that the FTP client
wasn't one you'd written yourself and that it was in a mobile situation.

Obviously you need a download method that you have complete control over or
which provides you with some progress monitoring feedback before you can go
about displaying progress.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top