我想使用代理连接下载文件。我的示例代码是:
WebClient client = new WebClient();
WebProxy wp = new WebProxy("url_proxy_server");
//wp.Credentials = new NetworkCredential("id", "pass", "domain");
client.Proxy = wp;
client.DownloadFile("http:mylink", "Save Path");
这是正确的下载模式吗?我如何设置端口号?
答案 0 :(得分:4)
使用其他构造函数(String,Int32)
WebProxy wp = new WebProxy("http://contoso", 80);
答案 1 :(得分:2)
您还可以在代理网址
中指定端口WebProxy wp = new WebProxy("url_proxy_server:proxyPort");