-2
1台のドライブサーバーにある大きなファイルをダウンロードしています。ダウンロード速度はWindows XPではかなり遅いです - httpwebrequest
通常、Windows 7にダウンロード速度は1500kb/sに達します。
Windows XPではダウンロードが500kb/sに達します。
これはおそらく何が原因でしょうか?
private void DownloadFileRange(string sSourceURL, string sDestinationPath)
{
long iFileSize = 0;
int iBufferSize = 8192;
long tamanioArchivoExistente = 0;
System.IO.FileStream saveFileStream;
System.Net.HttpWebRequest hwRq;
System.Net.HttpWebResponse hwRes;
try
{
if (System.IO.File.Exists(sDestinationPath))
{
System.IO.FileInfo fINfo = new System.IO.FileInfo(sDestinationPath);
tamanioArchivoExistente = fINfo.Length;
}
if (tamanioArchivoExistente > 0)
saveFileStream = new System.IO.FileStream(sDestinationPath, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
else
saveFileStream = new System.IO.FileStream(sDestinationPath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
hwRq = (HttpWebRequest)HttpWebRequest.Create(sSourceURL);
hwRq.Proxy = null;
//Esto funciona con NET 3.5
if (tamanioArchivoExistente > 0)
{
hwRq.AddRange(tamanioArchivoExistente);
}
hwRes = (HttpWebResponse)hwRq.GetResponse();
iFileSize = hwRes.ContentLength + tamanioArchivoExistente;
System.IO.Stream smRespStream;
smRespStream = hwRes.GetResponseStream();
if (tamanioArchivoExistente > 0)
{
bytesDescargados = tamanioArchivoExistente;
}
int iByteSize;
byte[] downBuffer = new byte[iBufferSize];
while ((iByteSize = smRespStream.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
saveFileStream.Write(downBuffer, 0, iByteSize);
}
}
}
マシンのハードウェアは同じですか? – maccettura
私は2つのWindows XP PCで試したが、1つは1GbのRAMを持ち、350kb/sをダウンロードし、2GBのRAMをダウンロードしたものは450kb/sだったが、RAMの欠陥 – AlanRubinoff