WebClient DownloadFileAsync with resume support-VBForums
Results 1 to 15 of 15

Thread: WebClient DownloadFileAsync with resume support

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,823

    WebClient DownloadFileAsync with resume support

    Here's a simple DownloadFileAsync class that allows resuming and also returns a few extra properties, like download speed, download time and remaining time. You can specify the update frequency (no delay, every 500ms or every second), so the ProgressChanged event doesn't fire continuously and hog CPU when updating controls.

    The added example also shows you how to create an ownerdrawn ListView, so you can draw a custom progressbar, in order to show the download progress.

    This version only supports Http downloads, because that's what most people use DownloadFileAsync for.

    The DownloadFileAsyncExtended, HttpWebRequestState, FileDownloadProgressChangedEventArgs and FileDownloadCompletedEventArgs classes have been added to a single file for convenience. You might want to put each class in its own file.

    I'm sure there are a few things that can be improved, so comments are welcome.

    I had to remove all executables from the project before posting it here. You might get a warning "Could not find type 'SampleProject.ListViewExtended'". In that case, Build the sample project first and restart the project.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Chris001; Jan 19th, 2012 at 11:34 PM.

  2. #2
    Addicted Member
    Join Date
    Jun 2008
    Location
    Macedonia
    Posts
    188

    Re: WebClient DownloadFileAsync with resume support

    nice project
    MACEDONIA 4EVER

  3. #3
    Fanatic Member
    Join Date
    Mar 2009
    Location
    place where VB is learned ..www.vbforums.com
    Posts
    730

    Re: WebClient DownloadFileAsync with resume support

    Thanks , Very Nice but something is missing there .. when we close the application with resuming half download of any file .. in next attempt it is not there .. please add after resuming if application is closed in next attempt we should be promoted to continue previous resumed download..

  4. #4
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Location
    On the Internet
    Posts
    3,216

    Re: WebClient DownloadFileAsync with resume support

    Quote Originally Posted by janu View Post
    Thanks , Very Nice but something is missing there .. when we close the application with resuming half download of any file .. in next attempt it is not there .. please add after resuming if application is closed in next attempt we should be promoted to continue previous resumed download..
    Of course it's not there; the program doesn't know you want to keep it. Granted, you can do that [there are Downloading Applications out there that do such a thing], it just requires a bit more code.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,823

    Re: WebClient DownloadFileAsync with resume support

    Quote Originally Posted by janu View Post
    Thanks , Very Nice but something is missing there .. when we close the application with resuming half download of any file .. in next attempt it is not there .. please add after resuming if application is closed in next attempt we should be promoted to continue previous resumed download..
    Sorry, but I'm not going to add that. It seems you have misunderstood what this code is about. The normal WebClient class rejects the Range header, preventing you from downloading only a part of the file, thus resuming. This class allows you to download files, just like you would do with the normal WebClient class, but this one supports resuming.

    The included project is just a Sample Project, that simply shows you how to use the download class and nothing more. Remembering partially finished downloads and other features is something you'll have to add yourself... you are the programmer

  6. #6
    New Member
    Join Date
    Oct 2012
    Posts
    1

    Re: WebClient DownloadFileAsync with resume support

    Thanks for this. I learned a LOT from it. I program in C# and was using WebClient to transfer files between PCs around the country in our network. I found you by Googling about doing resumes.
    - You got me to switch to HttpWebRequests
    - I converted your DownloadFileAsyncExtended.vb to a C# version using http://www.developerfusion.com/tools.../vb-to-csharp/ (not bad!) and some tweaks
    - The passing around of ListViewItems sure made my job easier
    - I also like storing the DownloadFileAsyncExtended objects in the ListViewItem Tags. I often have a problem figuring out how to trace my steps and find out where I'm coming from
    - Hate to admit it, but I'd never used SmallImageList before. Very cool.
    - This is a really great foundation for extending it to do resumes after restarting. My basic setup on this project is to try to keep files at remote sites in sync with "local" files

    Just wanted to thank you for sharing your work. I don't take the time to do that enough in this generous online community of programmers we have on the Internet.

  7. #7
    New Member
    Join Date
    Mar 2013
    Posts
    1

    Re: WebClient DownloadFileAsync with resume support

    excellent project, thank you. I translated it to C#, http_multiDownloader.zip attached is the Visual Studio 2010 solution in C#

  8. #8
    New Member
    Join Date
    Jul 2013
    Posts
    2

    Re: WebClient DownloadFileAsync with resume support

    Can I use this code in my project?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,823

    Re: WebClient DownloadFileAsync with resume support

    Quote Originally Posted by babythong View Post
    Can I use this code in my project?
    Yes, you are free to do with it whatever you want.

  10. #10
    New Member
    Join Date
    Jul 2013
    Posts
    2

    Re: WebClient DownloadFileAsync with resume support

    Thank you very much !

  11. #11
    New Member
    Join Date
    Oct 2013
    Posts
    5

    Re: WebClient DownloadFileAsync with resume support

    Nice Its Very Good Project^^

  12. #12
    New Member
    Join Date
    Sep 2013
    Posts
    3

    Re: WebClient DownloadFileAsync with resume support

    when I try to download the project it just downloads a file named attachment.php

    how can I download the sample project?

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,823

    Re: WebClient DownloadFileAsync with resume support

    Try to right-click on the link and select "Save Link As...", "Save Target As..." or something like that, depending on which browser you use.

  14. #14
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,090

    Re: WebClient DownloadFileAsync with resume support

    Dang, I wish I saw this earlier! I was working on my own. Thanks for doing this awesome work!

    Visual Studio 2010

  15. #15
    New Member
    Join Date
    Mar 2014
    Posts
    1

    Re: WebClient DownloadFileAsync with resume support

    Very Niceeeeee,TNX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.