Reputation: 129
I have noticed that when I go to PUT a file using WinSCP that it fails with a code 2 error stating that:
{WinSCP.SessionRemoteException: File or folder 'fileToPut.xml' does not exist. ---> WinSCP.SessionRemoteException: System Error.
Code: 2. The system cannot find the file specified
--- End of inner exception stack trace ---
at WinSCP.OperationResultBase.Check()
at transferWinSCP(String fileName) in c:\Program.cs:line 136}
However, just before it hits this line:
TransferOperationResult transferResult = session.PutFiles(fileName, path, false, transferOptions);`
I make sure that fileName indeed exists.
Any thoughts?
Here is my code:
using (Session session = new Session())
{
//start Log
session.SessionLogPath = logPath;
//connect
session.Open(sessionOptions);
//upload
TransferOptions transferOptions = new TransferOptions {TransferMode = TransferMode.Binary};
if (File.Exists(fileName))
{
TransferOperationResult transferResult = session.PutFiles(fileName, path, false, transferOptions); //put the file on the ftp server
transferResult.Check();
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.Write("upload of {0} succeeded", transfer.FileName);
}
}
}
Upvotes: 1
Views: 1700
Reputation: 96
I am currently having the same issue. however i have found that if you change the path around instead of using "\" trying "/" gets a different result sometimes. thought you might want to give it a try. but at the moment changing it around does not help for me so i'm stuck in the same boat.
Upvotes: 1