C# Cannot Open Session
Hi,
where I encounter an exception while trying this piece of code. All help appreciated... Thanks In Advance
Exception:Thrown: "The process cannot access the file 'C:\Users\user\AppData\Local\Temp\wscp1840.01F9ED70.tmp' because it is being used by another process." (System.IO.IOException)
A System.IO.IOException was thrown: "The process cannot access the file 'C:\Users\user\AppData\Local\Temp\wscp1840.01F9ED70.tmp' because it is being used by another process."
Exception:Thrown: "Host key wasn't verified!" (WinSCP.SessionRemoteException)
A WinSCP.SessionRemoteException was thrown: "Host key wasn't verified!"
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "192.0.0.10",
UserName = "user",
SshPrivateKeyPath = "private.ppk",
SshHostKeyFingerprint = "ssh-dss 1024 xx:xx:Xx:xx:Xx:xx:xx:Xx:xx:xx"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\test.txt", "/home/Testing/", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
}
where I encounter an exception while trying this piece of code. All help appreciated... Thanks In Advance
Exception:Thrown: "The process cannot access the file 'C:\Users\user\AppData\Local\Temp\wscp1840.01F9ED70.tmp' because it is being used by another process." (System.IO.IOException)
A System.IO.IOException was thrown: "The process cannot access the file 'C:\Users\user\AppData\Local\Temp\wscp1840.01F9ED70.tmp' because it is being used by another process."
Exception:Thrown: "Host key wasn't verified!" (WinSCP.SessionRemoteException)
A WinSCP.SessionRemoteException was thrown: "Host key wasn't verified!"
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "192.0.0.10",
UserName = "user",
SshPrivateKeyPath = "private.ppk",
SshHostKeyFingerprint = "ssh-dss 1024 xx:xx:Xx:xx:Xx:xx:xx:Xx:xx:xx"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\test.txt", "/home/Testing/", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
}