10.44 GiB
30 files
1.69 MiB/s
22 m 29 s
Method:
private void Download(string Filename, WebClient Client)
{
int BytesDownloaded = 0;
using (var s = new System.IO.StreamReader(File.OpenRead(Filename)))
{
while ((BytesDownloaded = Client.DownloadData(s.ReadToEnd()))!= 0)
{
// Note that the BytesDownloaded value includes the headers.
}
}
}
Since the response from the server is very large.
A:
Consider a third-party content downloader
The response from the server is most likely compressed, so it will be faster to download the response in one or more parts than to wait for the entire response to be completely downloaded.
Think of something like:
var client = new WebClient();
var path = "";
// decompress and save response content.
var decompressed = client.DownloadData(path);
// download only a fraction of the response content
var part1 = client.DownloadData("");
// download only a fraction of the response content
var part2 = client.DownloadData("");
// and so on.
However, make sure the server sends correct Content-Encoding and Accept-Encoding headers.
var client = new WebClient();
var path = "";
// don't trust Accept-Encoding header, but do trust content-encoding header.
if (client.Headers["Accept-Encoding"] == null)
client.Headers.Add("Accept-Encoding", "identity");
// decompress and save response content.
var decompressed = client.DownloadData(path); ac619d1d87
Related links:
Comments