.NET Server sent command exit status 0
Hi,
I am newbie at WinSCP, but this task have been assigned to me:
1) Create app to upload files via SFTP
but problem is:
1) Form WinSCP application already works and host name, user name etc. are correctly set
2) But when I want to create my application I am receiving this error:
Error: WinSCP.SessionRemoteException: Connection has been unexpectedly closed. Server sent command exit status 0.
Then there is a stack trace with Authentication failed error.
This is code I use:
I would guess that problem is somewhere in the code because the form application works fine.
Thanks for any help. As I said I am really newbie in this and I am kind a lost here...
I am newbie at WinSCP, but this task have been assigned to me:
1) Create app to upload files via SFTP
but problem is:
1) Form WinSCP application already works and host name, user name etc. are correctly set
2) But when I want to create my application I am receiving this error:
Error: WinSCP.SessionRemoteException: Connection has been unexpectedly closed. Server sent command exit status 0.
Then there is a stack trace with Authentication failed error.
This is code I use:
try { // Setup session options SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "190.56.75.08", UserName = "globus", //Password = "", SshHostKeyFingerprint = "ssh-rsa 1536 1f:00:35:19:90:82:ec:b4:1d:18:2f:fe:df:65:da:12", SshPrivateKeyPath = @"C:\keys\privatekey.ppk" }; using (Session session = new Session()) { // Connect Console.WriteLine("Trying to connect..."); session.Open(sessionOptions); Console.WriteLine("Connected."); Console.WriteLine(""); // Upload files Console.WriteLine("Trying to upload files..."); TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; TransferOperationResult transferResult; transferResult = session.PutFiles(@"C:\winscp515\test.xml", "/batches/in", false, transferOptions); Console.WriteLine("Uploaded."); Console.WriteLine("Check transfer result..."); // Throw on any error transferResult.Check(); Console.WriteLine("Checked."); Console.WriteLine(""); // Print results foreach (TransferEventArgs transfer in transferResult.Transfers) { Console.WriteLine("Upload of {0} succeeded", transfer.FileName); } } return true; } catch (Exception e) { Console.WriteLine("Error: {0}", e); return false; }
I would guess that problem is somewhere in the code because the form application works fine.
Thanks for any help. As I said I am really newbie in this and I am kind a lost here...