Download latest file from SFTP server using VB.NET
Hi all,
I'm a bit new to using SFTP assembly AND vb.net. I've managed to setup the connection and download all files to my local folder via
What I'm struggling with is to only get the latest file from the folder, I've checked the examples found on this site, but they don't give me the vb.net syntax i would need.
my current simplified sample code:
who can help me in the right direction?
kr,
LT
I'm a bit new to using SFTP assembly AND vb.net. I've managed to setup the connection and download all files to my local folder via
session.GetFiles
. I understand this will just get everything what's in the folder.
What I'm struggling with is to only get the latest file from the folder, I've checked the examples found on this site, but they don't give me the vb.net syntax i would need.
my current simplified sample code:
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
kr,
LT