无法从网络下载整个文件的问题 [英] Issue with not downloading entire file from web
本文介绍了无法从网络下载整个文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我在使用WebClient.DownloadFile命令时遇到问题.它可以处理较小的文件,但是当我尝试使用它下载约300MB的文件时,它并不会下载整个文件.
这是我到目前为止的内容:
Hi everyone!
I am running into an issue with using the WebClient.DownloadFile command. It works with small files, but when I try to use it to download ~300MB file, it doesn''t download the entire file.
Here is what I have so far:
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadFileAsync(new Uri(@"https://mysite/waveform_db.sdf"), @"c:\db.sdf");
推荐答案
此API非常简化.对于较大的文件,可以在连接断开或应用程序终止以及其他高级情况下继续下载,请使用System.Net.HttpWebRequest
:
http://msdn.microsoft.com/en-us/library/system.net. httpwebrequest.aspx [ ^ ].
您可以下载实现了继续下载"功能的现成应用程序HTTPDownloader的源代码,并查看其工作方式:
如何从Internet下载文件 [ ^ ].
另请参阅我过去的答案:
FTP:下载文件 [如何从中下载文件Asp.net 2.0中的服务器 [
This API is very much simplified. For bigger files, the ability to continue downloading after connection was lost or application terminated and other advanced cases, useSystem.Net.HttpWebRequest
:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].
You can download the source code of my ready-to-use application HTTPDownloader with that implements that "continue downloading" feature and see how it works:
how to download a file from internet[^].
See also my past answers:
FTP: Download Files[^],
how to download a file from the server in Asp.net 2.0[^].
—SA
这篇关于无法从网络下载整个文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文