我使用此代码下载文件Web客户端:下载未完成:远程服务器返回错误:(403)禁止。
private WebClient client;
client = new WebClient();
if (isBusy)
{
client.CancelAsync();
isBusy = false;
this.downloadButton.Text = "Download";
}
else
{
try {
Uri uri = new Uri(urlTextBox.Text);
this.downloadProgressBar.Value = 0;
client.Headers.Add("User-Agent: Other");
client.DownloadFileAsync(uri, "test.csv.zip");
this.downloadButton.Text = "Cancel";
isBusy = true;
}
catch (UriFormatException ex) {
MessageBox.Show(ex.Message);
}
}
但我得到一个错误的错误是
Download Not Complete: The remote server returned an error: (403) Forbidden.
我不知道为什么它是未来。
但是当我使用的URI在免费下载管理器中下载其工作
我加入这一行
client.Headers.Add("User-Agent: Other");
但它仍然没有工作。
会有很大的升值,如果有人可以帮助我。
在此先感谢。
整个列表这看起来像一个问题特定的网站,而不是C#。你可以从其他网站下载吗? –
你是否通过小提琴手来运行这两个请求(工作与非工作),看看有什么不同? –
我可以从网站下载文件,并通过下载管理器购买不通过此代码 –