We have not implemented the Connect method in the IFtp interface because of the different nature of SFTP and FTP(/SSL) protocols. I.e. there is no SSL mode in SFTP and there is the rub. So the question would be what SSL mode would be used then? And if you choose one of the variants (implicit/explicit/no SSL mode for FTP), the others would fail.
So the solution would not be universally suitable.
However we are planning to create a class which would be universal for both SFTP and FTP protocols. This would implement the Connect method. We will post here, once it is ready.
Update: The universal SFTP/FTP client class has been released as part of Rebex File Transfer Pack 2014 R2. It implements IFtp
and adds Connect
and Login
methods.
Meanwhile, could you call the Connect and Login methods just after instantiating the Ftp or Sftp object as in the code below?
public IFtp GetIFtpInstance()
{
// connect to a server according to its type
switch (serverType)
{
case "ftp":
// create an instance of Ftp object
var ftp = new Ftp();
// connect and authenticate to an FTP server
ftp.Connect(hostname);
ftp.Login(username, password);
// return Ftp instance
return ftp;
case "sftp":
// create an instance of Sftp object
var sftp = new Sftp();
// connect and authenticate to an SFTP server
sftp.Connect(hostname);
sftp.Login(username, password);
// return Sftp instance
return sftp;
default:
throw new Exception("Invalid server type.");
}
}