This project is read-only.

Failure on UploadFile

Aug 18, 2011 at 2:06 AM

I can't get the file to upload. Here's the code I'm using:

sshClient = New SshClient(strInternetProtocolAddress, 22, "username", "password")
sshClient.Connect()
If sshClient.IsConnected = True Then
    test = New SftpClient(sshClient.ConnectionInfo)
    test.Connect()
    test.ChangeDirectory("/path/to/remote/directory")
    stmStreamToImage = IO.File.OpenRead("path\to\local\file")
    test.UploadFile(stmStreamToImage, ".")
End If
 sshClient = New SshClient(strInternetProtocolAddress, 22, "root", "ZXCasdqwe123")
            sshClient.Connect()

            If sshClient.IsConnected = True Then

                test = New SftpClient(sshClient.ConnectionInfo)
                test.Connect()
                test.ChangeDirectory("/var/www/vhosts/chskeyaccess.com/CHSKEYACCESS_IMAGES/")
                stmStreamToImage = IO.File.OpenRead("C:\Users\Paul\Pictures\KamenRiderWAppProgress1.jpg")
                MessageBox.Show(test.WorkingDirectory)
                test.UploadFile(stmStreamToImage, ".")


            End If
sshClient = New SshClient(strInternetProtocolAddress, 22, "username", "password")
sshClient.Connect()

If sshClient.IsConnected = True Then

    test = New SftpClient(sshClient.ConnectionInfo)
    test.Connect()
    test.ChangeDirectory("/path/to/remote/directory/")
    stmStreamToImage = IO.File.OpenRead("path\to\local\file")
    test.UploadFile(stmStreamToImage, ".")

End If

It's reporting the error:

Renci.SshNet.Common.SshException: Failure
   at Renci.SshNet.Sftp.SftpSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
   at Renci.SshNet.Sftp.SftpSession.RequestOpen(String path, Flags flags, Boolean nullOnError)
   at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, SftpUploadAsyncResult asynchResult)
   at Renci.SshNet.SftpClient.UploadFile(Stream input, String path)
   at SSH.NET_Test.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Paul\documents\visual studio 2010\Projects\SSH.NET Test\Form1.vb:line 33

 

Does anyone know the cause of the problem? I'm currently using SharpSSH in my application and it's giving me grief, so I'm trying to figure SSH.NET out.

Aug 18, 2011 at 2:35 AM

Nevermind. I got it. Forgot to specify a filename on the remote end.

Jun 18, 2012 at 7:29 PM

Thanks for replying to your own question, i was getting the same error and this helped me quite a bit : )

Sep 5, 2012 at 10:26 AM

Thanks a lot for this information. I was getting this error and solved my issue