Description |
The FileDateToDateTime function converts an Integer FileDate value (as obtained from FileAge for example) to a more manageable TDateTime format.
There are many routines in Delphi that can work on this TDateTime format.
|
|
Related commands |
DateTimeToFileDate |
|
Convert a TDateTime value to a File date/time format |
FileAge |
|
Get the last modified date/time of a file without opening it |
FileSetDate |
|
Set the last modified date and time of a file |
|
|
|
Example code : Convert the last modified date of a file into a TDateTime value |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses SysUtils, // Unit containing the FileDateToDateTime command Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
fileName : string;
fileDate : Integer;
begin // 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 = '+
DateToStr(FileDateToDateTime(fileDate)));
end; end.
|
Hide full unit code |
Unit1.DCU last modified date = 10/11/2002
|
|