SFTP File Retrieval With .Net

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:

James Kite
Web Transactional Developer with Beacon since July 2012, using primarily .NET and Sql Server. James has a Degree in CIS from High Point University. Outside of work he enjoy books, movies, gaming, and spoiling my two Golden Retrievers.
Load More Posts