Ranger1234
Ranger1234

Reputation: 31

Using SSH Renci with VB.net how do I upload a file to a Raspberry Pi?

I have been trying to workout how to upload a file from a Windows PC to a Raspberry pi using the Renci SSH with VB.net. There are plenty of C# demos and tutorials but nothing on file uploading with VB.net.

I have used the following code:

https://github.com/muxall/Automation/blob/master/CiscoSshClientTest/CiscoSshClientTest/Form1.vb

This code allows me to send commands

Upvotes: 0

Views: 2260

Answers (1)

Ranger1234
Ranger1234

Reputation: 31

I just found this very simple answer online...

Upload file to SFTP server using VB.NET

` 

   SFTPHost = "192.168.1.xx"
        SFTPPort = "22"
        SFTPUsername = "pipi"
        SFTPPassword = "xxxxx"
        SFTPFolderSource = ""
        SFTPFolderDest = ""

    '   Dim sClient As New SftpClient(SFTPHost, SFTPPort, SFTPUsername, SFTPPassword)
    '   sClient.Connect()

    Dim client As SftpClient = New SftpClient(SFTPHost, SFTPPort, SFTPUsername, SFTPPassword)
    client.Connect()
    Try


        Using stream As Stream = File.OpenRead("C:\Users\xxxxx\Documents\xxxxx.txt")
            client.UploadFile(stream, "xxxxx.txt")
        End Using

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try`

Upvotes: 1

Related Questions