Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Download latest file from SFTP server using

Thanks! got it to work with the snippet you provided.

Download latest file from SFTP server using VB.NET

Hi all,

I'm a bit new to using SFTP assembly AND 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 syntax i would need.

my current simplified sample code:
    Using session As New Session
        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)
        For Each transfer In transferResult.Transfers
            Console.WriteLine("Download of {0} succeeded", transfer.FileName)
    End Using
    Return 0
Catch e As Exception
    Console.WriteLine("Error: {0}", e)
    Return 1
End Try

who can help me in the right direction?