Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharpssh directory listing

Tags:

c#

sftp

sharpssh

I'm writing an application that allows me to up- and download files from a remote server. I'm using sftp as my transfer protocol and i need to list all files and directory's into a listview. I'm using sharpssh for sftp. Can somebody point me into the right direction?

Thanks in forward,

Bas van Ooyen

like image 693
Bash Avatar asked Jun 21 '10 20:06

Bash


1 Answers

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();
like image 151
Gabriel Guimarães Avatar answered Sep 20 '22 05:09

Gabriel Guimarães