Hello to all, i have create a downloader in C# using downloadFile() method and i would like to get the progress percentage into progress bar.
I using downloadFile() and not using native stream object.
Any code is welcome.
Thanks.
Printable View
Hello to all, i have create a downloader in C# using downloadFile() method and i would like to get the progress percentage into progress bar.
I using downloadFile() and not using native stream object.
Any code is welcome.
Thanks.
What is downloadFile() method coming from ?
Is this a third Party dll or which namespace is used there ?
Are you using a backgroundworker ? During Download is there any possibility to get an event fired which updates your progress bar ?
Is this a WinForm or a WebApplication ? Using ADO or Linq ?
You see there are much questions left:D Please give more data.
What is ownloadFile() method coming from ?
From system.Net.WebClient class.
Is this a third Party dll or which namespace is used there ?
M$ library.
Are you using a backgroundworker ? During Download is there any possibility to get an event fired which updates your progress bar ?
I want it using backGroundworker. Yes, i want some event to update my progress bar in background to avoid my application get starvation.
Is this a WinForm or a WebApplication ? Using ADO or Linq ?
You see there are much questions left Please give more data.
Winform and not WPF.
I not using stream to calculate the file size. Is there any method ?
Thanks.
Have you looked at the methods and events associated with the webclient class? I don't see any methods or properties that will tell you the size of the file your downloading. I don't have much experience with that class. So I may have missed something.
-zd
if you're using the WebClient class it's very easy to display progress, you can handle for exaple this event DownloadProgressChanged
If i am not mistaken the downloadprogresschanged event is only fired with the DownloadfileAsync method. However even when wired up to the downloadprogresschanged event I don't think you would have any way of knowing what the total size of the file was so your progress bar would just have to be constantly moving. Which is OK....I guess.
That is to the best of my knowledge....
-zd
the DownloadProgressChangedEventArgs returns everything one could need
http://msdn.microsoft.com/en-us/libr...s_members.aspx
memeloo is correct the DownloadProgressChangedEventArgs class does provide all information needed. However, the link memeloo provided was for the System.Deployment.Application namespace. The DownloadProgressChangeEvent args class we need is in the system.net namespace located here:
http://msdn.microsoft.com/en-us/libr...s_members.aspx
Also this event is only triggered when the DownloadFileAsync method is used. In our case we are using the DownloadFile method.
However, if Peter decided to use the DownloadFileAsync memeloo is absolutely correct.
-zd
oh I'm sorry for the wrong link, sure, zdavis' link is the correct one of course, I just googled for DownloadProgressChangedEventArgs and didn't see that this is the wrong namespace
@memeloo - I figured that was the issue. I learned a lot from this post. especially on that event args class...
Good Post
I decided to using DownloadFileAsync.
Does anyone have code for DownloadProgressChanged and DownloadFileComplete ?
Thanks.
Does anyone have sample code for this topic ?
Thanks.
Are you having troubles with it?
-zd
you don't like msdn, do you? there are some samples