How to get Login Status of User using FTP instance?

0 votes
asked May 18, 2010 by imran (160 points)
edited Dec 6, 2013

Hi, I have an issue in which I would appreciate your help. The scenario is that I am connecting to an FTP server by getting values from Database. In the same method, where i am connecting the FTP with the server, I am also calling the FTP.login(xx,xxx) method. The problem i am facing is that I can keep track of FTP State, whether it is Ready, or Disconnected etc. from the property. But I am unable to know whether the User was logged in successfully or not. I mean if the connection was successful, but for some reason, an error occurred in the Login method, how am i supposed to know whether the user is successfully logged in or not? Thanks in advance !

Applies to: Rebex FTP/SSL

4 Answers

0 votes
answered May 18, 2010 by Lukas Matyska (61,230 points)
edited May 18, 2010

If the Ftp.Login method failed the FtpException is thrown. If no exception is thrown user was successfuly logged in (you don't need to check any log-in status).

0 votes
answered Oct 10, 2013 by kaycee1 (230 points)
edited Oct 10, 2013

the problem is when failing to connect, the State is still on "Ready". so catching with FtpException not really indicates if connection succeeded or not.

for example, if you do binding to the State, Ready doesn't mean you are connected.

0 votes
answered Oct 11, 2013 by Tomas Knopp (58,890 points)
edited Oct 11, 2013

In fact FtpState is now very close to being deprecated, for instance the new versions for Xamarin.iOS and Xamarin.Android will not contain it all.

It often causes confusion for users, because in fact it is related to the FTP protocol rather than actual state of the FTP connection. I.e. FtpState.Ready means that it is possible to send FTP commands but does not say anything about the usability of the FTP connection. It used to have sense in the historical releases of Rebex FTP where 1 method corresponded exactly to 1 FTP command.

Unless needed (which is really rare) we suggest - do not used the State property and use Rebex Ftp like this:

bool ready = false;
Ftp ftp = new Ftp();
    ftp.Login("user", "pass");

    // here you are connected and authenticated, so
    // either continue the work right here
    // or indicate that you are ready
    ready = true;
catch(FtpException ex)

We are working on a better way of determining if you are connected or authenticated and we will post here when it will be released.

0 votes
answered Dec 6, 2013 by Lukas Matyska (61,230 points)
edited Dec 6, 2013

From Version 2013 R3 you can use Ftp.IsConnected and Ftp.IsAuthenticated properties to check the Login Status.