Skip to content

FileAge

Return the timestamp of a file.

Declaration

Source position: filutilh.inc line 180

  function FileAge(const FileName: UnicodeString) : Int64;
  function FileAge(const FileName: UnicodeString; 
                  out FileDateTime: TDateTime; FollowLink: Boolean)
                   : Boolean;
  function FileAge(const FileName: RawByteString; 
                  out FileDateTime: TDateTime; FollowLink: Boolean)
                   : Boolean;
  function FileAge(const FileName: RawByteString) : Int64;

Description

FileAge returns the last modification time of file FileName. The FileDate format can be transformed to TDateTime format with the FileDateToDateTime function.

Fileage cannot be used on directories, it will return -1 if FileName indicates a directory.

Errors

In case of errors, -1 is returned.

See also

Name Description
FileDateToDateTime Convert a FileDate value to a TDateTime value.
FileExists Check whether a particular file exists in the file system.
FileGetAttr Return attributes of a file.

Example

Program Example36;
{ This program demonstrates the FileAge function }
Uses sysutils;
Var S : TDateTime;
    fa : Longint;
Begin
  fa:=FileAge('ex36.pp');
  If Fa<>-1 then
    begin
    S:=FileDateTodateTime(fa);
    Writeln ('I''m from ',DateTimeToStr(S))
    end;
End.