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 in session.open(MySessionOption)

Please set Session.DebugLogPath and post or email me the log.
VaskezNS

Im not sure but have you tried specifying full path to your file instead of @"test.txt" ?
acandela

Error in session.open(MySessionOption)

Hello
I'm using WinSCP in an application .net c# whit winscp.dll library(the code below), but when i go to execute the "session.open(MySessionOption)", i get the error message "System.IO.FileNotFoundException".
Can you tell me where is the mistake?
Thanks



SessionOptions MySessionOption = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "server.com",
UserName = "user",
Password = "password",
SshHostKey = "ssh-rsa 1024 ab:3e:c1:b0:49:d0:f0:99:83:8f:ca:f9:cb:2f:24:35",
PortNumber=22
};

using (Session session = new Session())
{
// Connect
session.ExecutablePath = @"C:\Programm\WinSCP\WinSCP.exe";
session.DisableVersionCheck = true;
session.Open(MySessionOption);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"test.txt", "/upload/test.txt", false, transferOptions);

// Throw on any error
transferResult.Check();

}