Sample code for 30+ languages & platforms
PowerBuilder

Set a Remote FTP File's Last-Modified Time

See more FTP Examples

Demonstrates the Chilkat Ftp2.SetRemoteFileDateTimeStr method, which sets the last-modified time of a remote file. The first argument is an RFC 822 date-time string and the second is the remote filename.

Background: An upload normally leaves the remote file stamped with the time it arrived, which loses the original modification time — a problem for backups, mirrors, and timestamp-based sync. This method restores it, and Chilkat converts the supplied time to UTC before sending a server-supported command (typically MFMT). Whether it is honored depends on the server implementing such a command and granting permission.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

//  Demonstrates the Ftp2.SetRemoteFileDateTimeStr method, which sets the last-modified time of a
//  remote file.  The 1st argument is an RFC 822 date-time string and the 2nd is the remote
//  filename.

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

//  Chilkat converts the date to UTC and sends a server-supported timestamp-setting command.
li_Success = loo_Ftp.SetRemoteFileDateTimeStr("Fri, 10 Jul 2026 20:15:30 -0600","public_html/report.pdf")
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "Remote file timestamp set."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp