Click here to Skip to main content
15,868,102 members
Articles / Multimedia / GDI+

MyDownloader: A Multi-thread C# Segmented Download Manager

Rate me:
Please Sign up or sign in to vote.
4.95/5 (418 votes)
12 Feb 2008CPOL10 min read 2.1M   124.7K   1.3K  
Sample application that manages multiple segmented downloads and supports HTTP, FTP and YouTube video downloads
using System;
using System.Collections.Generic;
using System.Text;
using MyDownloader.Core;

namespace MyDownloader.Extension.SpeedLimit
{
    public class ProtocolProviderProxy: IProtocolProvider
    {
        private IProtocolProvider proxy;
        private SpeedLimitExtension speedLimit;

        #region IProtocolProvider Members

        public void Initialize(Downloader downloader)
        {
            proxy.Initialize(downloader);
        }

        public System.IO.Stream CreateStream(ResourceLocation rl, long initialPosition, long endPosition)
        {
            return new LimitedRateStreamProxy(proxy.CreateStream(rl, initialPosition, endPosition), speedLimit);
        }

        public RemoteFileInfo GetFileInfo(ResourceLocation rl, out System.IO.Stream stream)
        {
            RemoteFileInfo result = proxy.GetFileInfo(rl, out stream);

            if (stream != null)
            {
                stream = new LimitedRateStreamProxy(stream, speedLimit);
            }

            return result;
        }

        #endregion

        public ProtocolProviderProxy(IProtocolProvider proxy, SpeedLimitExtension speedLimit)
        {
            this.proxy = proxy;
            this.speedLimit = speedLimit;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions