Главная страница | назад





Article #28328: Getting the date of a file using Delphi.

QUESTION:


How can one get the date of a file programmatically?


ANSWER:


Place a TOpenDialog component on a form along with a TButton and a TLabel. Place the following code in Button1.OnClick event:

procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.Execute; //Use the TOpenDialog component to select the file we are interested in
Label1.Caption := DateToStr(FileDateToDateTime(FileAge(OpenDialog1.FileName)));
end;


Last Modified: 05-FEB-02