Code Monkey home page Code Monkey logo

.netfiledownloader's Introduction

.NET File Downloader

This is a HTTP(S) file downloader with support of caching and resuming of partially downloaded files. The main goal of .NET File Downloader is to facilitate downloading of big files on bad internet connections. It supports resuming of partially downloaded files. So if the download is interrupted and restarted, only the remaining part of file would be downloaded again.

Why not simply use the file download functionality from the .NET Framework?

Unfortunately System.Net.WebClient.DownloadFile() has no support for resuming downloads. It might work fine for small files or over stable internet connections. Once you want to download bigger files via poor internet connections it is not sufficient anymore and downloads will fail.

License

FileDownloader is open source software, licensed under the terms of MIT license. See LICENSE for details.

Examples

Create simple fileDownloader

    IFileDownloader fileDownloader = new FileDownloader.FileDownloader();

Create fileDownloader with download cache

    IFileDownloader fileDownloader = new FileDownloader.FileDownloader(new DownloadCacheImplementation());

Start download

    IFileDownloader fileDownloader = new FileDownloader.FileDownloader();
    fileDownloader.DownloadFileCompleted += DownloadFileCompleted;
    fileDownloader.DownloadFileAsync(picture, dowloadDestinationPath);
    
    void DownloadFileCompleted(object sender, DownloadFileCompletedArgs eventArgs)
    {
            if (eventArgs.State == CompletedState.Succeeded)
            {
                //download completed
            }
            else if (eventArgs.State == CompletedState.Failed)
            {
                //download failed
            }
    }    

Report download progress

    FileDownlaoder fileDownloader = new FileDownloader.FileDownloader();
    fileDownloader.DownloadProgressChanged += OnDownloadProgressChanged;
    fileDownloader.DownloadFileAsync(picture, dowloadDestinationPath);

    void OnDownloadProgressChanged(object sender, DownloadFileProgressChangedArgs args)
    {
		Console.WriteLine("Downloaded {0} of {1} bytes", args.BytesReceived, args.TotalBytesToReceive)
    }

Cancel download

    fileDownloader.CancelDownloadAsync()

Resume download

In order to resume download, IDownloadCache should be provided to the FileDownloader constructor. DownloadCache is used to store partially downloaded files. To resume a download, simply call one of the download file methods with the same URL.

How to build FileDownlader

At least Visual Studio 2013 and .NET Framework 3.5 are required to build. There are no other dependencies.

.netfiledownloader's People

Contributors

sebastian-faller avatar stephan-brenner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.