locked
FTP PASS command from C# RRS feed

  • Question

  • I am trying to log onto FTP. My connection works fine, my USER command results in a 331 (request for password). However, whenever I put through the PASS command I get a 331 back.

    The user name and passoword work fine when I FTP from the command prompt.

    Following are the commands once the connection is made.

    SendCommand("USER anonymous", socketC);

    iR = ReadReply(str, socketC);

    SendCommand("PASS xyz@hotmail.com", socketC);

    iR = ReadReply(str, socketC);

    private void SendCommand(String str, Socket s)

    {

    ASCIIEncoding ascii = new ASCIIEncoding();

    String strSend = str + "\r\n";

    Byte[] bSend = ascii.GetBytes(strSend);

    int iR = s.Send(bSend);

    }

    Thank you for your help!

    ERK

    Friday, October 7, 2005 1:13 PM

Answers

  • Thank you all for your help. The receive is defined as a StringBuilder, not a String, so the reply was being appended (the reply was correct - the old information was still there).

    Have a great day.

    ERK
    Friday, October 14, 2005 4:28 PM

All replies

  • If yu get another 331, maybe the login/password are not correct ?

    Maybe you can take a look at this source:

    http://www.csharphelp.com/archives/archive9.html

    to help you to do what you want :)

    HTH.

    Bye.
    Saturday, October 8, 2005 4:17 PM
  • I checked the user name and password by using the command prompt - they worked there (it's anonymous, so any password would work, but I used the one from my code). The code itself is basically the same as that in the sample, which was quite helpful when I programmed this.

    I am extremely confused - this combination works from the command prompt, but not from the code. The USER command is accepted - it comes back with the 331 (another command without the USER results in an error, so the command is being processed).

    The PASS is then not being processed correctly. Is there something I'm missing in the form of it? I suspect it's something simple that I'm just not seeing.

    Thank you

    E

    Saturday, October 8, 2005 7:53 PM
  • I'm sorry but I've really no idea of why you have this problem...


    Sorry.
    Monday, October 10, 2005 11:42 AM
  • Thank you all for your help. The receive is defined as a StringBuilder, not a String, so the reply was being appended (the reply was correct - the old information was still there).

    Have a great day.

    ERK
    Friday, October 14, 2005 4:28 PM