Unfortunately the protocol doesn't provide such feature. In most cases you need to know upfront what settings to use.
Basically there are three modes in which Ftp.dll can work:
Plain - regular FTP connection, no security (port 21) - Connect method.
Implicit – where FTPS client immediately connects using secure channel (default port is 990) - ConnectSSL method.
Explicit – where FTP client connects on unsecured channel first (Connect on port 21) and then secures the communication by issuing AUTHTLS command (AuthTLS method).
After you connect on plain port, you may check if server supports explicit option and secure the connection:
client.Connect("ftp.example.com");
if (client.Extensions.SupportsAuthTLS)
{
client.AuthTLS();
}
Generally I think your client should allow users to choose. For example:
- Use plain FTP (insecure) - Use Connect
- Use explicit FTP over SSL/TLS, if available - use Connect and AuthTLS, if SupportsAuthTLS
- Require explicit FTP over SSL/TLS - use Connect and AuthTLS
- Require implicit FTP over SSL/TLS - use ConnectSSL