Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multipart Downloading in C#?

Please excuse my ignorance on the subject.

I would like to write an application in C# that can download files off a server the same way DownThemAll does. DownThemAll seems to open four connections to the HTTP server to download the same file. I was just wondering if there are any existing libraries that might do this.

Here is a quote from their site about this feature:

DownThemAll features a smart download technique called ‘multipart download’. It splits files into multiple sections, which are downloaded simultaneously.

I would also like to be able to pause/resume the downloads. That's the basic functionality I would like, I don't necessarily need a full fledged download manager library, but if there is one that can do these things then I'd love to know about them too. The files are in a password protected directory hosted with lighttpd, so I would also need some way to authenticate myself.

If there aren't any pre-existing libraries that I can use, then what .net classes should I look into that might be able to do this?

Thanks!

EDIT: Reworded the title to be more appropriate and added a quote from the DownThemAll site explaining what it is.

2nd EDIT: I believe svens posted the most appropriate answer so far, although as a comment :/ It's my fault since I misworded the title as I did not know what I was talking about. He posted an article which goes over HTTP download pausing/resuming. It also talks about the Range header which is what I think I'm supposed to use:

The Range header is capable of asking for more than one range in one single request, a feature called "multipart ranges." Don't confuse this with segmented downloading, which almost all downloading tools use to increase the speed of the download. These tools claim to improve download speed by opening two or more simultaneous connections, each of which requests a different range of the file.

So I take it I want to use the range to download certain parts of the file concurrently. Then again this probably doesn't have any advantage over just downloading the file in one go. I'll just do that and allow for pausing/resuming.

Thanks guys!

P.S svens, go ahead and post the comment as an answer so that I can accept it if you want.

like image 838
Jorge Israel Peña Avatar asked Oct 12 '09 21:10

Jorge Israel Peña


3 Answers

Pardon the posting to an article older than the Christ, but this:

http://www.codeproject.com/Articles/21053/MyDownloader-A-Multi-thread-C-Segmented-Download-M

seems to be closer to what was asked.

The currently marked 'correct answer' is good for supplying the server side partial download routine, it goes someway to explaining what the HTTP Range headers do, but it's no download client.

like image 123
Jeremy Lake Avatar answered Nov 15 '22 11:11

Jeremy Lake


I'm with svens on this, http://www.devx.com/dotnet/Article/22533/0/page/2 seems to say it all.

like image 32
csharptest.net Avatar answered Nov 15 '22 11:11

csharptest.net


The System.Net.HttpClient class should be able to download your files. Just call this class from a thread or a thread pool and you can download lots of files at the same time.

like image 20
David Avatar answered Nov 15 '22 11:11

David