Click to See Complete Forum and Search --> : Update Progess File


Peter_APIIT
May 7th, 2009, 04:03 AM
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.

JonnyPoet
May 7th, 2009, 08:21 AM
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.

Peter_APIIT
May 8th, 2009, 03:19 AM
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.

zdavis
May 8th, 2009, 08:18 AM
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

memeloo
May 8th, 2009, 08:27 AM
if you're using the WebClient class it's very easy to display progress, you can handle for exaple this event DownloadProgressChanged

zdavis
May 8th, 2009, 08:42 AM
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

memeloo
May 8th, 2009, 08:45 AM
the DownloadProgressChangedEventArgs returns everything one could need

http://msdn.microsoft.com/en-us/library/system.deployment.application.downloadprogresschangedeventargs_members.aspx

zdavis
May 8th, 2009, 09:01 AM
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/library/system.net.downloadprogresschangedeventargs_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

memeloo
May 8th, 2009, 09:17 AM
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

zdavis
May 8th, 2009, 09:20 AM
@memeloo - I figured that was the issue. I learned a lot from this post. especially on that event args class...

Good Post

Peter_APIIT
May 9th, 2009, 03:53 AM
I decided to using DownloadFileAsync.

Does anyone have code for DownloadProgressChanged and DownloadFileComplete ?

Thanks.

Peter_APIIT
May 15th, 2009, 11:21 PM
Does anyone have sample code for this topic ?

Thanks.

zdavis
May 18th, 2009, 09:07 AM
Are you having troubles with it?

-zd

memeloo
May 18th, 2009, 09:33 AM
you don't like msdn, do you? there are some samples