i need to download a big data from the server,because the data is so big,i am not able to download it at a time,do you have any idea?Thanks you very much.
问题:
回答1:
If the server supports it, you can use HTTP byte ranges to request specific parts of the file.
This page describes HTTP byte range requests: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
The following code creates a request which will ask to skip the first 100 bytes, but return the rest of the file:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://example.com/somelargefile");
request.Headers.Add("Range", "bytes=100-");
回答2:
The only logical way I can think about doing it is to pre-arrange the data into chunks for download with index. The index increments with the number of chunks received, so when the server sends down the file, it knows it can skip (chunkCount * chunkSize)
from the byte stream and begin sending down the next chunkSize
bytes.
Of course, this would mean a rather excessive number of requests, so YMMV.
回答3:
There is a Background Transfer Service code sample on MSDN that might help. I've never used it, but the sample might give you a place to start from.