How can I set lastwritetime with actual date/time under windows?

Hello short question:
i want to set the lastwritetime with the actual date/time under windows like in powershell (ls ".\Forager.lnk").lastwritetime = get-date ?
thx

Your best bet is to use the cross-platform filetime crate.

use filetime::{set_file_mtime, FileTime};
use std::time::SystemTime;

fn main() {
    let ts = FileTime::from_system_time(SystemTime::now());
    set_file_mtime("Forager.lnk", ts).unwrap();
}

@thombles thx

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.