Click here to Skip to main content
15,916,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frds,

I m getting the "The remote server returned an error: (407) Proxy Authentication Required." Exception while running the below code to access a remote file from FTP system.

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://"+FtpServerName+FtpFilePath);
request.Method = WebRequestMethods.Ftp.DownloadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential(FtpUserId, FtpPassword);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();
Posted

1 solution

That means that your communication goes through a proxy server, and taht proxy server requires authentication. Before calling request.GetResponse(), do:
C#
request.Proxy = new WebProxy("Address-of-my-proxy");
request.Proxy.Credentials = new NetworkCredential("proxy-username", "proxy-password");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900