martin wrote:
OK, I've missed that the directory
is result of session.ListDirectory
is your code.
You have to pass a path as a string to the first argument of session.EnumerateRemoteFiles
.
Like: session.EnumerateRemoteFiles("/home/user/")
No overload for method 'EnumerateRemoteFiles' takes 1 arguments. "[String: 16; Column: 19]
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.sftp,
HostName = "server.com",
UserName = "user",
Password = "pass",
SshHostKeyFingerprint = "ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:1f"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
var directory = session.ListDirectory("/home/user/);
//var filesCount = session.EnumerateRemoteFiles(directory.ToString(), null, EnumerationOptions.AllDirectories);
//var directoriesCount = session.EnumerateRemoteFiles(directory.ToString(), null, EnumerationOptions.AllDirectories | EnumerationOptions.EnumerateDirectories).Where(file => file.IsDirectory);
return filesCount.Count() ;
session.Close();
}