I need to connect to an ftp and download a file from it, but I'm unable to connect to it. I've specified the credentials and am able to connect through my browser, but not through .NET.
FtpWebRequest downloadRequest = (FtpWebRequest)WebRequest.Create(ftpSite + "/" + TOC);
downloadRequest.Method = WebRequestMethods.Ftp.DownloadFile;
downloadRequest.Credentials = new NetworkCredential(userName, pass);
FtpWebResponse response = (FtpWebResponse)downloadRequest.GetResponse(); //execption thrown here
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
reader.ReadLine();
while (!reader.EndOfStream)
data.Add(reader.ReadLine());
reader.Close();
It throws a WebException
with the 407 error and I'm not quite sure why. My boss is baffled as well. Any insight?