Skip to content

Instantly share code, notes, and snippets.

@jorgepsmatos
Last active August 22, 2019 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgepsmatos/7e5bc67a7ed1fb4730dfc5dde9938bbd to your computer and use it in GitHub Desktop.
Save jorgepsmatos/7e5bc67a7ed1fb4730dfc5dde9938bbd to your computer and use it in GitHub Desktop.
public void ListDirectory(string remoteDirectory, string host, string username, string password)
{
try
{
using (var sftpClient = new SftpClient(host, username, password))
{
sftpClient.Connect();
var files = sftpClient.ListDirectory(remoteDirectory);
foreach (var file in files)
{
Console.WriteLine(file.Name);
}
sftpClient.Disconnect();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment