Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. File segmentation

File segmentation

Scheduled Pinned Locked Moved C#
csharpquestionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    profoundwhispers
    wrote on last edited by
    #1

    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..."

    H 1 Reply Last reply
    0
    • P profoundwhispers

      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..."

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 (see HttpWebRequest.BeginGetResponse) as opposed to handling threads yourself. You can implement a ProgressBar by using HttpWebResponse.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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups