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

Author Message
diamantr
[View user's profile]

Joined: 2015-07-06
Posts: 2
Location: Israel
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

Description: (none)

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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
diamantr
[View user's profile]

Joined: 2015-07-06
Posts: 2
Location: Israel
prikryl 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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Yes the SFTP is preferred over SCP.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License