.NET Specifiy Initial Remote Directory
Hello,
I currently try to get an SFTP connection to work with the .NET Assembly.
What I do is the following (see code). But I can't get this to work. I should mention I have no read or write permissions to the root directory only to a directory called /OUT. But I haven't found any possiblity to specify the Initial Remote directory before session.Open. Has anyone a hint for me about this issue?
The session.Open(sessionOptions) throws following expection:
An unhandled exception of type 'WinSCP.SessionRemoteException' occurred in WinSCPnet.dll
Additional information: Connection has been unexpectedly closed. Server sent command exit status 0. Authentication failed.
The thing is a generated this information with Winscp Windows program and the settings are right. I also added the password which is not added by default in generated code.
I can connect by commmand line of Winscp and with Winscp GUI so the settings should be correct.
I currently try to get an SFTP connection to work with the .NET Assembly.
What I do is the following (see code). But I can't get this to work. I should mention I have no read or write permissions to the root directory only to a directory called /OUT. But I haven't found any possiblity to specify the Initial Remote directory before session.Open. Has anyone a hint for me about this issue?
The session.Open(sessionOptions) throws following expection:
An unhandled exception of type 'WinSCP.SessionRemoteException' occurred in WinSCPnet.dll
Additional information: Connection has been unexpectedly closed. Server sent command exit status 0. Authentication failed.
The thing is a generated this information with Winscp Windows program and the settings are right. I also added the password which is not added by default in generated code.
I can connect by commmand line of Winscp and with Winscp GUI so the settings should be correct.
namespace Test { class Program { static void Main(string[] args) { var sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "...", UserName = "...", Password = "...", SshHostKeyFingerprint = "...", SshPrivateKeyPath = @"FILE", }; using (Session session = new Session()) { // Connect sessionOptions.AddRawSettings("AuthGSSAPI", "..."); sessionOptions.AddRawSettings("Cipher", "..."); sessionOptions.AddRawSettings("KEX", "..."); session.Open(sessionOptions); var result = session.ListDirectory("/OUT"); } } } }