How to upload a single file with multiple threads in C #

I want to upload a single file with Multi-Threads in C #. for example: Thread1 starts loading from 1% to 40%. Thread2 starts downloading from 41% to 70%. Thread3 starts downloading from 71% to 100%

Please offer me the code. thanks in advance

+5
source share
3 answers

How about using the HttpRequest class with a call to the AddRange method. This should be a header with an offset from which to start the download.

    var request = HttpWebRequest.Create(new Uri("http://www.myurl.com/hugefile"));

    request.Method = "GET";
    request.AddRange(offset_for_this_thread);  // I assume you have calculated this
                                               // before firing threads
    Stream reponseStream = request.GetResponse().GetResponseStream();

You can then read the data from the'responseStream 'report and combine it with other streams when this is done.

, , , , , - ... Windows wil .

+4

, Range HTTP header. , ( )

- HttpWebRequest . : HttpWebRequest WebRequest - ASP.NET

, ( FileStream)

+4

AddRange . HTTP , , . .

, . Imho , , X . IP, - . .

+2

All Articles