Get the last modified date/time of a file without opening it SysUtils unit
 function FileAge(const FileName string):Integer;
The FileAge function returns the last modified date and time of a file FileName.
There is no need to open or close the file - this function handles these operations silently for you.
The returned value is in a 32 bit partitioned format. Use the FiledateToDateTime function to convert into a manageable TDateTime value.
If the file date could not be found (for example, the FileName was invalid), then -1 is returned.
Related commands
DateTimeToFileDateConvert a TDateTime value to a File date/time format
FileDateToDateTimeConverts a file date/time format to a TDateTime value
FileSetDateSet the last modified date and time of a file
FileGetAttrGets the attributes of a file
FileSetAttrSets the attributes of a file
 Download this web site as a Windows program.

Example code : Get the last modified date of the current Unit form file
  fileName   : string;
  fileDate   : Integer;

  // Try to open the Unit1.DCU file for the current project
  fileName := 'Unit1.DCU';
  fileDate := FileAge(fileName);

  // Did we get the file age OK?
  if fileDate > -1 then
    ShowMessage(fileName+' last modified date = '+
Show full unit code
  Unit1.DCU last modified date = 10/11/2002
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page