views:

522

answers:

4

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.

+1  A: 

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.

David
Thanks I appreciate it, but I didn't mean to say that I want to download various files at the same time. DownThemAll opens four connections to the HTTP server somehow to download the /same/ file.
Jorge Israel Peña
HttpClient is probably easier than Http.Get... +1
overstood
They refer to it as 'multipart downloading'.
Jorge Israel Peña
A: 

The System.Net.WebrequestMethods.Http namespace is a good place to start. You probably want to use a Get to pull down the files that you want.

http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.http.aspx

overstood
A: 

you can use BITS (Background Intelligent Transfer Service) a good article more information http://msdn.microsoft.com/en-us/library/aa362708%28VS.85%29.aspx http://www.codeproject.com/KB/IP/bitsman.aspx

ashish jaiman
+1  A: 

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

csharptest.net
Thanks. Since he said it first, I'll wait a while to see if he posts it as an answer so that I can accept it. Else it'll go to you for the sake of closure on this question.
Jorge Israel Peña