5

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

谢谢转发,

巴斯·范·欧延

4

1 回答 1

13
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();
于 2010-11-23T00:17:10.273 回答