[英]Download file from proxy server using c#
I want to download file using a proxy connection. 我想使用代理连接下载文件。 My example code is: 我的示例代码是:
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");
Is this a correct mode to download? 这是一个正确的下载模式吗? How i can set port number? 我怎么设置端口号?
Using the other constructor (String, Int32) 使用其他构造函数(String,Int32)
WebProxy wp = new WebProxy("http://contoso", 80);
http://msdn.microsoft.com/en-us/library/xfsh37cx.aspx http://msdn.microsoft.com/en-us/library/xfsh37cx.aspx
您还可以在代理URL中指定端口
WebProxy wp = new WebProxy("url_proxy_server:proxyPort");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.