Click here to Skip to main content
12,400,183 members (50,810 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
How to download files from SFTP server using C#
Posted 8-Nov-12 23:38pm
Dee_Bee3.5K
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You can use for this purpose ComponentPro[^]. The following code demonstrates that:

using ComponentPro.Net;
using ComponentPro.IO;
 
...
 
// Create a new instance.
Sftp client = new Sftp();
 
// Connect to the SFTP server.
client.Connect("myserver");
 
// Authenticate.
client.Authenticate("userName", "password");
 
// ...

// Get all directories, subdirectories, and files from remote folder '/myfolder' to 'c:\myfolder'.
client.DownloadFiles("/myfolder", "c:\\myfolder");
 
// Get all directories, subdirectories, and files that match the specified search pattern from remote folder '/myfolder2' to 'c:\myfolder2'.
client.DownloadFiles("/myfolder2", "c:\\myfolder2", "*.cs");
 
// or you can simply put wildcard masks in the source path, our component will automatically parse it.
// download all *.css files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
client.DownloadFiles("/myfolder2/*.css", "c:\\myfolder2");
 
// Download *.cs and *.vb files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
client.DownloadFiles("/myfolder2/*.cs;*.vb", "c:\\myfolder2");
 
// Get files in the folder '/myfolder2' only.
TransferOptions opt = new TransferOptions(true, RecursionMode.None, false, (SearchCondition)null, FileExistsResolveAction.Overwrite, SymlinksResolveAction.Skip);
client.DownloadFiles("/myfolder2", "c:\\myfolder2", opt);
 
// ...

// Disconnect.
client.Disconnect();


For more examples see:
http://www.componentpro.com/sftp/[^]
  Permalink  
v4
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Check this link, may help you

http://www.sftp-net.com/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 23 Jan 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100