Reputation: 31
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
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