Mega Code Archive

 
Categories / Delphi / Files
 

Get datetime of creation of file

Title: Get date/time of creation of file Use FileAge function, which returns date and time stamp of file. Use this result in FileDateToDateTime function for converting to TDateTime type. procedure TForm1.Button1Click(Sender: TObject); var FAge: Integer; FileParam: TDateTime; begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; FAge:=FileAge(Edit1.Text); FileParam:=FileDateToDateTime(FAge); Label2.Caption:='Date of creation - '+DateToStr(FileParam); Label3.Caption:='Time of creation - '+TimeToStr(Fileparam); end;