0

I need to create a C# client with .NET Framework 4.6.2 to connect a server.

My client offers me the possibility to connect to a SFTP server or to a FTPS server, but I don't know which one is the best to connect with.

On this page, I have found this:

No built-in SSH/SFTP support in VCL and .NET frameworks

I need to connect to a server to upload and download files. I also need to monitor a directory on the server to know when a file is on that remote directory.

Searching on Internet I'm not sure if the .NET libraries (SSHNet) that implements SFTP protocol are good enough to a production environment.

I think SFTP is the best option to use but FTPS could be easier to implement a C# client for it.

Or maybe I can use libssh2 to implement a C program that do the job to monitor a remote directory, download any new file on it and upload the files that I need to upload.

Any advice?

VansFannel
  • 45,055
  • 107
  • 359
  • 626
  • What kind of things will you need to do with the server later? Just upload o download a single file, or are you looking at full “FTP client” functionality here? Is bundling an executable an option? – poke Jan 30 '17 at 07:47
  • 2
    SFTP and FTPS are different things with different features. The choice between them depends not only of what‘s easily available but of your needs ! – AFract Jan 30 '17 at 07:48
  • @poke I need to connect to a remote server to upload and download files. I also need to monitor a directory on the server to know when a file is on that remote directory. – VansFannel Jan 30 '17 at 07:50
  • @AFract My client offers me the possibility to connect to a SFTP server or to a FTPS server, but I don't know which are the best to connect with. – VansFannel Jan 30 '17 at 07:52
  • I've posted an answer. I recommend FTPS, but your needs are still not totally clear. – AFract Jan 30 '17 at 08:23

1 Answers1

2

If both protocols are fine for your actual needs (as suggested in your question and comments), if it's only a matter of "what's the easiest to use in .Net", I would simply go for FTPS.

It's very fast to implement, since you'll find all what you need in the framework ("FtpWebRequest" class, or more recently "WebClient", etc), even on old versions of the framework.

You can find plenty resource about this on the web or on SO

You have mentioned that you need to "monitor" a folder on remote server. Of course there's no problem with FTPS to retrieve the list of all files of a folder, but it will be in "pull" mode, as frequently as you wish. There's no way for the server itself to push you a notification every time a new file has been dropped. So if you need some real-time notifications, it's not optimal.

Community
  • 1
  • 1
AFract
  • 8,868
  • 6
  • 48
  • 70