【发布时间】:2012-09-03 01:30:59
【问题描述】:
这是我正在使用的代码:
private bool CheckPartialDL(String url)
{
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(url);
hwr.Method = "HEAD";
hwr.AddRange(0);
try
{
HttpWebResponse hwbresp = (HttpWebResponse)hwr.GetResponse();
if (hwbresp.StatusCode == HttpStatusCode.PartialContent)
{
hwbresp.Close();
return true;
}
}//end of try
catch (WebException wbe)
{
MessageBox.Show(wbe.Message, "Error");
}//end of catch
return false;
}//end of Check
但是服务器返回如下错误:
远程服务器返回错误:(416) 请求的范围不可满足。
我要下载以下文件格式:
http://windowsclient.net/sitefiles/1000/wpf/videos/source-code/creatingavideoapp-part1.zip
当我使用 IDM 检查恢复能力时,idm 显示它可用。
那么我提供的代码哪里错了?
【问题讨论】:
-
小问题,但仅供参考:WebRequest 是 .NET 的一部分,而不是 C# 的一部分。
标签: c# httpwebrequest download httpwebresponse