Hello,
FTP and SFTP are two different file transfer protocols. Rebex provides two different components, represented by Ftp and Sftp classes.
There is also IFtp interface which encapsulates methods, properties and events, which are defined in Ftp class as well as in Sftp class.
If your application needs connecting to both FTP and SFTP servers, the IFtp interface allows you to write most of the code just once (for both protocols).
The iFTP interface can be used like this:
// declare a protocol-independent variable
IFtp client;
// connect to the server according to its type
switch (serverType)
{
case "ftp":
// create instance of Ftp object
var ftp = new Ftp();
// connect and authenticate to an FTP server using FTP/SSL Explicit
ftp.Connect(hostname, SslMode.Explicit);
ftp.Login(username, password);
// assign the Ftp instance to an IFtp variable
client = ftp;
break;
case "sftp":
// create instance of Sftp object
var sftp = new Sftp();
// connect and authenticate to an SFTP server
sftp.Connect(hostname);
sftp.Login(username, password);
// assign the Sftp instance to an IFtp variable
client = sftp;
break;
default:
throw new InvalidOperationException();
}
// the remaining code works with both FTP and SFTP connection
client.ChangeDirectory(targetDirectory);
client.PutFile(@"c:\data\file.txt", "file.txt");
// even disconnecting can be done using IFtp
client.Disconnect();
For more information about SFTP and FTP difference see http://www.rebex.net/kb/secure-ftp/default.aspx
If you have already purchased the SFTP component or FTP component you can upgrade to Rebex File Transfer Pack (it contains both SFTP and FTP components). Upgrading within 90 days after original purchase costs the price difference only.