string user = "user";
string password = "password";
string ip = "ip";
string path = "/etc"; // Путь к папке
IZennoList foldersList = project.Lists["folders"];
using (SftpClient ftp = new SftpClient(ip, 22, user, password))
{
try
{
ftp.Connect();
var files = ftp.ListDirectory(path);
ftp.Disconnect();
foreach (var file in files)
{
if (file.IsDirectory)
{
if (file.Name !="." && file.Name != "..")
foldersList.Add(file.Name.ToString());
}
}
}
catch (Exception e)
{
project.SendErrorToLog(e.Message, true);
return null;
}
}