Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (180 points)
I've been using the free version of edtFTPnet for a while now and I use the code similar to this:

            FTPClient _ftp;
            _ftp = new FTPClient {RemoteHost = host};
            _ftp.Connect();
            _ftp.Login(username, password);
            _ftp.ConnectMode = FTPConnectMode.PASV;
            _ftp.TransferType = FTPTransferType.ASCII;


Not exactly the code, but very similar. Well, we've now purchased the pro version and I need to implement sftp. Is it possible for me to just change this block of code and still have all the other code that gets directory listings and adds/removes files to still work the same?

I tried changing FTPClient to SSHFTPClient but it has different methods and properties. Are there any good examples?

2 Answers

0 votes
by (180 points)
I was able to get this figured out.
0 votes
by (162k points)
For the benefit of other readers, here's our reply:

Yes, you can largely keep your code the same, with a few caveats (because they are completely different protocols).

ConnectMode doesn't exist in SFTP, so that isn't used. And Login is not required - just set the user/password and call Connect(). You'll need to set the ServerValidation = SecureFTPServerValidationType.None to get started.

Otherwise most code shouldn't need changing.

We do have a bunch of examples but they focus on SecureFTPConnection, which is a more recent API for a class that supports all protocols and just has a Protocol property.

http://www.enterprisedt.com/products/ed ... howto.html

It may not be worthwhile changing your code to use SecureFTPConnection.

Categories

...