Please find attached the session log file. The source code is displayed below:
Private Sub BtnWinScpUpload_Click(sender As Object, e As System.EventArgs) Handles BtnWinScpUpload.Click
Dim sessionOptions As New SessionOptions
Dim tim As TimeSpan = TimeSpan.FromMinutes(1000)
Try
' Setup session options
sessionOptions.Protocol = Protocol.Sftp
sessionOptions.HostName = TextHostName.Text.ToString.Trim '"example.com"
sessionOptions.UserName = TextUserCode.Text.ToString.Trim '"user"
sessionOptions.Password = TextPassword.Text.ToString.Trim '"mypassword"
sessionOptions.SshHostKeyFingerprint = TextHostKeyFingerPrint.Text.ToString.Trim '"ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
sessionOptions.Timeout = tim
Using session As New WinSCP.Session
session.SessionLogPath = "C:\TestSftp\test\WinScp.log"
'if WinScp.exe is not in same path than WinScp.dll, then use the below line to point to WinScp.exe
'session.ExecutablePath = "C:\Download and Documentation\WinScp\winscp577automation\WinSCP.exe"
' Connect
session.Open(sessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
'transferResult = session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions)
transferResult = session.PutFiles(TextLocalPath.Text.ToString.Trim & TextFileName.Text.ToString.Trim, TextRemotePath.Text.ToString.Trim, False, transferOptions)
' Throw on any error
transferResult.Check()
' Print results
For Each transfer In transferResult.Transfers
MessageBox.Show("Upload of file " & transfer.FileName & " succeeded")
Next
End Using
Catch ex As Exception
MessageBox.Show("BtnWinScpUpload_Click : " & ex.Message & vbCrLf & "Source :" & ex.Source & "Stack Trace : " & ex.StackTrace)
End Try
End Sub