Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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

Yes the SFTP is preferred over SCP.
diamantr

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
diamantr

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