SFTP File Retrieval With .Net

By | 2017-06-16T12:26:25+00:00 July 8th, 2015|Categories: Web Development|

Est. Reading Time: 1 minute

I am often tasked with developing .Net applications to interact with FTP servers for uploading and downloading files.  However, I was recently given a project involving file manipulation using SFTP (Secure File Transfer Protocol) and I was at a bit of a loss.  While there are endless online examples of using FTP with .Net, examples using SFTP were much scarcer.

Luckily for me, there is a wonderful SFTP client library specifically for .Net developed by Rebex:  http://www.rebex.net/sftp.net/.  Simply add the Rebex DLL file to your project, add a reference to it, and you’re ready to start accessing files from your application via SFTP.  I found it easier and cleaner to create a wrapper class to interact with the Rebex library.  From there it’s as simple as creating an instance of your wrapper class and downloading your files.  Complete code samples are below:

 

Example of using wrapper class to download file:

Wrapper class:

About the Author:

James Kite
James has served as the Senior Transactional Developer since July 2012, adding more than 15 years of overall IT experience to the Beacon team. He specializes in .Net and Sql Servers and has a strong knowledge of Cascade Server development, as well as Velocity programming. James holds a B.A. in Computer Information Systems from High Point University.