File segmentation
-
How can you go about developing a download manager in C# that would act as an accelerator (like Download Accelerator Plus) by segmenting the file into multiple fragments and downloading each simultaneously? Sammy "A good friend, is like a good book: the inside is better than the cover..."
-
How can you go about developing a download manager in C# that would act as an accelerator (like Download Accelerator Plus) by segmenting the file into multiple fragments and downloading each simultaneously? Sammy "A good friend, is like a good book: the inside is better than the cover..."
See the
HttpWebRequest.AddRange
method documentation in the .NET Framework SDK, which includes an example. The HTTP Range header specifies which byte range you want to get. See RFC 2616, Section 14, Subsection 35[^] for more information on the Range header. This is assuming that the HTTP daemon supports it. This is only supported in HTTP/1.1. Be sure to catch exceptions when it's not supported, though the server will most likely just hand you the entire file without complaining on a single request. For multi-threading, I recommend asynchronous calls (seeHttpWebRequest.BeginGetResponse
) as opposed to handling threads yourself. You can implement aProgressBar
by usingHttpWebResponse.GetResponseStream
and reading and writing the bytes to a file (in that loop is where you'd increment your progress bar).Microsoft MVP, Visual C# My Articles