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

peter594

Hello Martin,

first thanks for your answer. Enclosed the requested log, I removed all the personal information like URL, usernames etc. At says Disconnected: Unable to authenticate at the end but the login informations are exactly the same like when I enter it into the normal GUI. There it can connect. The only difference is in the GUI I also private in the Directory options a remote directory name.
martin

Re: .NET Specifiy Initial Remote Directory

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
peter594

.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.

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");
            }
        }
    }
}