Results 1 to 7 of 7

Thread: WebClient DownloadFileAsync with resume support

  1. #1
    Frenzied Member
    Join Date
    Nov 05
    Posts
    1,808

    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 08
    Location
    Macedonia
    Posts
    185

    Re: WebClient DownloadFileAsync with resume support

    nice project
    MACEDONIA 4EVER

  3. #3
    Hyperactive Member
    Join Date
    Mar 09
    Location
    place where VB is learned ..www.vbforums.com
    Posts
    412

    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 08
    Location
    On the Internet
    Posts
    2,845

    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
    Frenzied Member
    Join Date
    Nov 05
    Posts
    1,808

    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 12
    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 13
    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#

Posting Permissions

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