Rust Requires Chilkat v11.0.0+
Rust
FTP Set Remote File Date/Time Equal to Local File's Last-Modified Date/Time
See more FTP Examples
Demonstrates how to set a remote file's date/time to be equal to a local file's date/time.Important: Not all FTP servers support the ability to set a file's date/time.
Chilkat Rust Downloads
// This example assumes Chilkat Ftp2 to have been previously unlocked.
// See Unlock Ftp2 for sample code.
let ftp = chilkat::Ftp2::new();
ftp.set_hostname("www.authtls-ftps-server.com");
ftp.set_username("FTP_LOGIN");
ftp.set_password("FTP_PASSWORD");
ftp.set_auth_tls(true);
ftp.set_port(21);
// Connect to the FTP server using explicit TLS (AUTH TLS).
if ftp.connect_only().is_err() {
println!("{}", ftp.last_error_text());
return;
}
// Authenticate.
if ftp.login_after_connect_only().is_err() {
println!("{}", ftp.last_error_text());
return;
}
// We're going to get the last-mod date/time for the local file
// "qa_data/hamlet.xml", and then set the remote "hamlet.xml" to this date/time.
let fac = chilkat::FileAccess::new();
let dt = chilkat::DateTime::new();
let last_mod_timestamp = fac.get_file_time_str("qa_data/hamlet.xml", 0).unwrap_or_default();
let _ = dt.set_from_timestamp(&last_mod_timestamp);
if ftp.set_remote_file_dt(&dt, "hamlet.xml").is_err() {
println!("{}", ftp.last_error_text());
return;
}
let _ = ftp.disconnect();
println!("Success.");