I have the following code fragment that is trying to connect to an SFTP server built using OpenSSH (the server works because I was able to successfully connect to this FTP through the WinSCP client):
ConnectionInfo ConnNfo = new ConnectionInfo("127.0.0.1", 22, "usertest",
new AuthenticationMethod[]{
new PasswordAuthenticationMethod("usertest","usertest"),
}
);
using (var sftp = new SftpClient(ConnNfo))
{
sftp.Connect();
sftp.ChangeDirectory(@"/C:/IISFTP/");
using (var uplfileStream = File.OpenRead(uploadfn))
{
sftp.UploadFile(uplfileStream, uploadfn, true);
}
sftp.Disconnect();
}
When calling a string sftp.Connect(), the following exception occurs:
Message Type 80 Invalid
Why is this happening? How to connect to my SFTP server using SSH.NET?
thank
source
share