PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Ftp
li_Success = 0
// 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.
loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
destroy loo_Ftp
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "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.
loo_Ftp.Password = "myPassword"
li_Success = loo_Ftp.Connect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
li_Success = loo_Ftp.ChangeRemoteDir("public_html")
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// Only files modified on or after this date will be considered by DownloadTree. Files older
// than this are skipped.
loo_Ftp.SetOldestDateStr("Wed, 01 Jul 2026 00:00:00 -0000")
// Download only the recently-modified files in the remote tree.
li_Success = loo_Ftp.DownloadTree("qa_output/recent")
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
Write-Debug "Downloaded recently modified files."
li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
destroy loo_Ftp