SFTP File Retrieval With .Net

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

Est. Reading Time: 1 minutes

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
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.