2010-07-20 93 views
7

我正在尋找一個免費的SFTP客戶端。也應該有一個免費的DLL,我可以編寫代碼上傳和下載C#(.NET框架)文件。免費的SFTP客戶端與DLL上傳和下載文件在C#

例如下面的代碼是不是免費的,它有30天的免費評估,我想它是免費的,

Chilkat.SFtp sftp = new Chilkat.SFtp(); 

bool success; 
success = sftp.UnlockComponent("Anything for 30-day trial"); 

sftp.ConnectTimeoutMs = 5000; 
sftp.IdleTimeoutMs = 10000; 

int port; 
string hostname; 
hostname = "www.my-ssh-server.com"; 
port = 22; 
success = sftp.Connect(hostname,port); 

success = sftp.AuthenticatePw("myLogin","myPassword"); 

success = sftp.InitializeSftp(); 

string handle; 
handle = sftp.OpenFile("hamlet.xml","readOnly","openExisting"); 

success = sftp.DownloadFile(handle,"c:/temp/hamlet.xml"); 

success = sftp.CloseHandle(handle); 
MessageBox.Show("Success."); 
+0

http://stackoverflow.com/questions/1753709/implementing-sftp-in-2-0 http://stackoverflow.com/questions/530330/sftp-libraries-for-net – 2010-08-25 15:40:11

回答

6
我目前使用SharpSSH這是免費的,有一個非常好的簡單的界面

SharpSSH sourcefoge page.它具有您提到的所有身份驗證功能。

您可以在C#中做到這一點:

var sftp = new Sftp(hostName, userName, password); 
sftp.Connect(port); 
sftp.Put(putFilePath, toDir); 
sftp.Get(getFilePath); 
2

你可能想看看WinSCP。儘管它不是一個庫,但您可以編寫腳本來驅動它,鏈接是一個很好的教程,它向您展示瞭如何在C#和Visual Basic中實現它。

+1

現在WinSCP有[WinSCP。 NET程序集](http://winscp.net/eng/docs/library)作爲WinSCP腳本界面的.NET包裝。 – 2013-11-05 16:23:34