0

I have been digging through a mountain of posts on how to properly login to FTP in C# but when I actually try, it does not work. Through my readings I have come to think that it is because my username has the 'at' symbol in it. Is this true or is does it appear that there is something else wrong? I am able to login using FileZilla no problem.

var file = f.Element("FILE_PATH").Value;
string ftpHost = "myFTP.com";

var URI = @"ftp://" + ftpHost + "/download/" + file; 
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(URI);
ftp.Credentials = new NetworkCredential(@"me@mysite.com", "Password");
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.DownloadFile;

FtpWebResponse ftpResponse = (FtpWebResponse)ftp.GetResponse();
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Mark Hollas
  • 1,107
  • 1
  • 16
  • 44
  • Can you loging without the @ in your username? – Hanlet Escaño Feb 19 '13 at 22:57
  • on FileZilla I can not – Mark Hollas Feb 19 '13 at 23:16
  • @MarkHollas are you able to view the connection log (from the server, for example)? Alternatively, could you use some sort of traffic sniffer to grab the FTP traffic and possibly post it? Lastly, try adding `ftp.UsePassive = true` – Jesse Feb 20 '13 at 00:36
  • `Mark Hollas` can you try to change this line `ftp.Credentials = new NetworkCredential(@"me@mysite.com", "Password");` to this line it should just be the username , password if I am not mistaked `ftp.Credentials = new NetworkCredential(yourUserName Here, "Password");` – MethodMan Feb 20 '13 at 01:13
  • also check into setting setting `ftp.UsePassive = true;` and `ftp.KeepAlive = true;` – MethodMan Feb 20 '13 at 01:16
  • @DJKRAZE I am not sure what you mean, should I create a string var before the ftp.Credential is called then use it in as the userName? string yourUserName = "me@mysite.com"; ftp.Credentials = new NetworkCredentials(yourUserName, "Password"); – Mark Hollas Feb 20 '13 at 17:16
  • 1
    Okay. I figured it out...The problem was in the ftp set-up. The FTP host set up the ftp with login / username for based on the credentials of my username /password of my user on their system. Since then I changed my user's password and just assumed that the ftp credentials would be changed as well..however the ftp password remained the same as the old one.. Sorry for the trouble..human error.. – Mark Hollas Feb 20 '13 at 17:47
  • 1
    @Mark Hollas - since you found a solution for your problem, you should copy the content of your comment to an answer, and then accept your answer. – DavidRR Aug 02 '14 at 23:45

0 Answers0