Here is a simple Delphi function that takes a file name as its input, and returns the date and time the file was created. Note that this returns the file creation date and time (creation date/time stamp). This means that if a file is copied from a different drive to a new drive, its creation date/time stamp is reset. Even if a file is copied from one directory (folder) to another directory (folder) on the same drive, the creation date/time stamp is reset. For additional Delphi code for the Windows operating system, see Useful Delphi Code for the Windows Operating System.
function GetFileCreationDateTime(FileName: String): TDateTime; begin GetFileCreationDateTime := 0;
If (FileName <> '') and (FileExists(FileName) = True) then begin GetFileCreationDateTime := TFile.GetCreationTime(FileName); //TFile record is found in the IOUtils unit end; end;