sample code to connect to SFTP just like WinSCP? (wodSFTP / wodSFTP.NET / wodSFTPdll)

by markazali, (100 days ago) @ Jasmine

here is sample code with private information removed. Setting blocking = true did not help

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Try

'Authenticate with server using hostname, login, password.
wodSFTP1.Hostname = "utftp.xxxxx.com"
wodSFTP1.Login = "xxxxx"
wodSFTP1.Password = "xxxxxx"
wodSFTP1.Port = 22
wodSFTP1.Blocking = True
Dim key As New WeOnlyDo.Security.Cryptography.Keys
wodSFTP1.Authentication = SFTP.Authentications.PublicKey
key.Load("myprivatekey.ppk")

wodSFTP1.Authentication = WeOnlyDo.Client.SFTP.Authentications.Both

wodSFTP1.PrivateKey = key.PrivateKey(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey)


wodSFTP1.Connect()

'After connection with server is successful download the file on your local system using only one method.
'wodSFTP1.GetFile("c:\", "/home/somepath/somefile.txt")

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

End Sub

Private Sub wodSFTP1_ConnectedEvent(Sender As Object, Args As SFTP.ConnectedArgs) Handles wodSFTP1.ConnectedEvent
If (Args.Error Is Nothing) Then
'GetFiles Method is used to download complete directory structure of some folder on server to local disk.
'In combination with LoopItem Event we can download only specific filenames.
wodSFTP1.GetFiles("c:\somelocalfolder", "/home/somefolder", 0)
Else
'Receive connection error here. If there were any.
MsgBox("Connected Error: " + Args.Error.Message)
End If
End Sub

Private Sub wodSFTP1_DisconnectedEvent(Sender As Object, Args As SFTP.ConnectedArgs) Handles wodSFTP1.DisconnectedEvent

End Sub


Complete thread: