odd behavior with C# ftp client class

Posted by geoff on Stack Overflow See other posts from Stack Overflow or by geoff
Published on 2010-03-17T18:10:20Z Indexed on 2010/03/17 18:11 UTC
Read the original article Hit count: 213

Filed under:

I found an ftp client class in c# over a year ago and have been using it in a process that uploads files on a nightly basis. A few days ago we started having a problem where it would time out. I'm not well versed in this so I'm not sure why it's doing this.

When the program starts uploading a file it checks to see if it's logged in and if not, it calls the login method. In that method is this block of code.

       if (this.resultCode != 230)
        {
            this.sendCommand("PASS " + password);

            if (!(this.resultCode == 230 || this.resultCode == 202))
            {
                this.cleanup();
                throw new FtpException(this.result.Substring(4));
            }
        }

On the line that says this.sendCommand("PASS"... it goes into this code.

    private void sendCommand(String command)
    {
        if (this.verboseDebugging) Debug.WriteLine(command, "FtpClient");

        Byte[] cmdBytes = Encoding.ASCII.GetBytes((command + "\r\n").ToCharArray());
        clientSocket.Send(cmdBytes, cmdBytes.Length, 0);
        this.readResponse();
    }

If I let the program run, it times out. However if I step through it into the sendCommand method it executes fine. Does anyone know why it would work fine when I step through it? Nothing on our end has changed and I've been told nothing on the client's end has changed so I'm stumped. Thanks.

© Stack Overflow or respective owner

Related posts about ftp-client