0

So this is my code, i basically copied and pasted from SharpSSH website.

Sftp oSftp = new Tamir.SharpSsh.Sftp(_ftpURL, _UserName, _Password);
oSftp.Connect(_Port);
oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory + "/" + FileName);
oSftp.Close();

When i run this, i get a "first chance exception" on oSftp.Connect(_Port)

A first chance exception of type 'Tamir.SharpSsh.jsch.JSchException' occurred in Tamir.SharpSSH.dll

Does anyone experienced with SharpSSH have any idea why this is happening? I have also tried uploading files to the server using Rubex but it gave me the same error.

Vibol
  • 615
  • 1
  • 8
  • 25

2 Answers2

0

First you need to pass only folder path of server and do not specify file name in that path.

oSftp.Put(LocalDirectory + "/" + FileName, _ftpDirectory);

and also make sure you have added below packages from nuget

Install-Package DiffieHellman Install-Package Org.Mentalis.Security

Niraj
  • 775
  • 7
  • 20
0

just check your path of file and path where you want to upload on sftp.

example:

Sftp sftp=new Sftp("host","username","pass");
sftp.Connect();

sftp.Put("path of your local file","path to upload file on sftp server");

sftp.Close();
J. Chomel
  • 8,193
  • 15
  • 41
  • 69