Posted: 2016-08-31 22:24
I'm able to download a specific file using the script below as described on this site:
Dim mySession As New Session
On Error Resume Next
Dim mySessionOptions As New SessionOptions
.Protocol = Protocol_Ftp
.HostName = "ftp.MySite.com"
.UserName = “MyName”
.Password = “MyPassword”
Dim directoryInfo As RemoteDirectoryInfo
Set directoryInfo = mySession.ListDirectory("/MyDir/")
'Get Latest File
Dim myTransferOptions As New TransferOptions
myTransferOptions.TransferMode = TransferMode_Binary
Dim transferResult As TransferOperationResult
Set transferResult = mySession.GetFiles(“/MyDir/MyFile.csv", “C:\Temp\”, False, myTransferOptions)
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
MsgBox "Download of " & transfer.FileName & " succeeded"
Unfortunately the script example provided for obtaining the latest file is written in C#
// Get list of files in the directory
RemoteDirectoryInfo directoryInfo = session.ListDirectory(remotePath);
// Select the most recent file
RemoteFileInfo latest =
Where(file => !file.IsDirectory)
.OrderByDescending(file => file.LastWriteTime)
I understand how to set the directoryinfo parameter, but does anyone have a VBA example of the query/properties/methods used to identify the most recent file?
Location: Prague, Czechia
In VBA, you have to iterate the
You can post new topics in this forum
And it's free!