Search code examples
c#sftpsharpssh

Exception of type 'Tamir.SharpSsh.jsch.SftpException' was thrown


Im able to connect to the sftp server am able to get the list of files in "pickup" directory. But I can't download any of those files. Here is my code:

try
{
    sftp.Get(txtRemotePath.Text + txtFixedFileName.Text, txtLocalPath.Text + txtFixedFileName.Text);
    //example:
    //txtRemotePath.Text + txtFixedFileName.Text = "/pickup/temp.txt";
    //txtLocalPath.Text + txtFixedFileName.Text = @"C:\Users\...\temp.txt"
}
catch (Exception ex)
{
    lblError.Text += "\n" + ex.Message;
}

I tried modifiying the local and remote paths switching betwen slashes "/" and back-slashes "\", removing/addding starting slashes in remote path.. unfortunatly same error is generated:

Exception of type 'Tamir.SharpSsh.jsch.SftpException' was thrown


Solution

  • check the sftp server security to allow you in through specific port