Error getting name of current remote directory when trying to get files using c#

Advertisement

diamantr
Joined:
Posts:
2
Location:
Israel

Error getting name of current remote directory when trying to get files using c#

Hi

I'm trying to get files on remote host using c#.
I keep getting the following error message.

Attached log file.
my code looks like this:

SessionOptions so = new SessionOptions();

so.Protocol = Protocol.Scp;
so.HostName = txtHost.Text;
so.UserName = txtUsername.Text;
so.Password = txtPassword.Text;

so.SshHostKeyFingerprint = "ssh-rsa 1040 4b:51:f4:5e:64:63:70:0b:cf:97:d4:cd:4c:d9:c6:4e";

using (Session session = new Session())
{
// Connect
session.SessionLogPath = "c:\\Roei\\log.txt";
session.Open(so);
MessageBox.Show("session opened!!!");

var dirInfo = session.ListDirectory("/home/");
session.Close();
MessageBox.Show(dirInfo.Files.Count.ToString());
}

Thanks

Roei
  • log.txt (38.55 KB, Private file)

Reply with quote

Advertisement

diamantr
Joined:
Posts:
2
Location:
Israel

Re: Error getting name of current remote directory when trying to get files using c#

martin wrote:

If possible use SFTP protocol, not SCP.

If you need to use SCP protocol, you can try to workaround the problem using:

so.AddRawSettings("LookupUserGroups2", "1");

See
https://winscp.net/eng/docs/rawsettings
https://winscp.net/eng/docs/ui_login_scp#other_options


Your workaround worked perfectly!!! Thanks!!!!
When i tried using SFTP i get error code 127.

For general knowledge, why SFTP is preferred over SCP?

Thanks again!

Roei

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Error getting name of current remote directory when trying to get files using c#

Yes the SFTP is preferred over SCP.

Reply with quote

Advertisement

You can post new topics in this forum