2010-06-21 62 views
5

我正在编写一个应用程序,允许我从远程服务器上传和下载文件。我使用sftp作为传输协议,我需要列出所有文件和目录到列表视图中。我使用sharpssh作为sftp。有人能指引我走向正确的方向吗?Sharpssh目录列表

感谢在前进,

巴斯面包车Ooyen

回答

12
Sftp sftp = new Sftp(serverUri.Host, userName, password); 

sftp.Connect(); 

//the foldername cannot be empty, or the listing will not show 
ArrayList res = sftp.GetFileList("/foldername"); 
foreach (var item in res) 
{ 
    if (item.ToString() != "." && item.ToString() != "..") 
     Console.WriteLine(item.ToString()); 
} 

sftp.Close(); 
+1

我基本上做同样的事情......我正在更新一些我们在HTTPS使用SharpSSH代码://到位桶.org/mattgwagner/sharpssh – MattGWagner 2011-04-19 13:48:01

+0

@MattGWagner不错的主动,很高兴知道。 – 2011-04-20 12:38:48