DataFlex
DataFlex
Limit FTP DownloadTree by Modification Date
See more FTP Examples
Demonstrates the Chilkat Ftp2.SetOldestDateStr method, which sets the oldest remote modification time eligible for DownloadTree. The only argument is an RFC 822 date-time string; files older than it are skipped. It is a void method.
Background: This is a date filter for the recursive download: set a cutoff and
DownloadTree pulls only files modified on or after it, ignoring everything older. It is ideal for fetching just recent activity — new logs, today's uploads — from a directory that also holds a large archive you do not want to re-download. The RFC 822 string carries a timezone so the cutoff is unambiguous.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
// Demonstrates the Ftp2.SetOldestDateStr method, which sets the oldest remote modification time
// eligible for DownloadTree. The only argument is an RFC 822 date-time string. It is a void
// method.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
Set ComPassword Of hoFtp To "myPassword"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComChangeRemoteDir Of hoFtp "public_html" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Only files modified on or after this date will be considered by DownloadTree. Files older
// than this are skipped.
Send ComSetOldestDateStr To hoFtp "Wed, 01 Jul 2026 00:00:00 -0000"
// Download only the recently-modified files in the remote tree.
Get ComDownloadTree Of hoFtp "qa_output/recent" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Downloaded recently modified files."
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure