Download file from proxy using c #

I want to download a file using a proxy connection. My example code:

        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 the correct boot mode? How can I set the port number?

+3


source to share


2 answers


Using a different constructor (String, Int32)

WebProxy wp = new WebProxy("http://contoso", 80);



http://msdn.microsoft.com/en-us/library/xfsh37cx.aspx

+4


source


You can also specify the port in the proxy url



WebProxy wp = new WebProxy("url_proxy_server:proxyPort");

      

+2


source







All Articles