Re: Download latest file from SFTP server using VB.net
Thanks! got it to work with the snippet you provided.
session.GetFiles
. I understand this will just get everything what's in the folder.
Try
Using session As New Session
session.open(sessionOptions)
Dim SourceFolder As String = session.HomePath & "/Test/"
Dim TargetFolder As String = "C:\Test\"
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
transferResult =session.GetFiles(SourceFolder, TargetFolder, False, transferOptions)
transferResult.Check()
For Each transfer In transferResult.Transfers
Console.WriteLine("Download of {0} succeeded", transfer.FileName)
Next
End Using
Return 0
Catch e As Exception
Console.WriteLine("Error: {0}", e)
Return 1
End Try