webclient中的错误........ [英] Error in webclient........

查看:53
本文介绍了webclient中的错误........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim downZip As WebClient = New WebClient()<br />
<br />
downZip.DownloadFile(sourceUrl,destinationFile)



运行此代码时,出现以下错误.

远程服务器返回了禁止的错误403 ...
我们该如何解决这个错误?请帮我朋友...



While running this code i am getting the following error.

remote server returned an error 403 forbidden...
How can we solve this error? Plz help me friends...

推荐答案

也许您必须使用NetworkCredentials ...

Perhaps you have to use NetworkCredentials...

WebClient wc = new WebClient();
NetworkCredential nc = new NetworkCredential("alex", "mypassword");
wc.Credentials = nc;
byte[] response = wc.DownloadData("http://www.java2s.com/index.htm");


这篇关于webclient中的错误........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆