What can I set to create / last change / last access to the file?

in: How to get file creation / last modified dates in Delphi? I found how to get the creation date / last modified / last access un file, but to set this value in the file, what can I do? Thank you very much.

+4
source share
2 answers

Try the SysUtils.FileSetDate function from the SysUtils block, which internally calls the SetFileTime WinApi function.

this function has two versions

 function FileSetDate(const FileName: string; Age: Integer): Integer; function FileSetDate(Handle: THandle; Age: Integer): Integer; 

The Age parameter is the installation time. To convert a TDateTime value to a Windows timestamp.

Like this

 FileSetDate(FileName, DateTimeToFileDate(Now)); 
+3
source

In the IOUtils.pas block IOUtils.pas you can find the corresponding methods in the TFile and TDirectory : SetCreationTime , SetLastAccesstime , SetLastWriteTime , followed by their UTC syntax errors.

+13
source

All Articles