Using WinSCP with variables to automate downloading of specific file from remote root folder. I have no problem connecting, but the code generates error 'No such file or directory' when attempting download.
Here's the code:
' Setup session variables, connect, and download file
Dim remotefile As String = "text.zip"
Dim localpath As String = "D:\Work\Returns\"
Dim sessionOptions As New SessionOptions
With sessionOptions
.Protocol = Protocol.Sftp
.HostName = myftpaddress
.UserName = myftpuser
.Password = myftppass
.SshHostKeyFingerprint = SSH
End With
Using session As New Session
'go ahead & connect
session.Open(sessionOptions)
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
'now get the file
transferResult = session.GetFiles("/" & remotefile, localpath, False, transferOptions)
End Using