file create date

How can I find Create date of a file?

I would like to write a delphi code that will tell me
 
the create and modify date of a particular file

Can anyone help me

Thanks in advance

Pandian
Pandian012000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Use FindFirst with the real file name and check the returned TWin32FindData structure. There is all you need.

Ciao, Mike
0
PeterLarsenCommented:
I agree with Mike,
There is a ready-to-use sample in the help file !

/PL
0
AttarSoftwareCommented:
Can I agree too? ;O)

Tim.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

LischkeCommented:
Quite heavy traffic for a 25 points question, isn't it? ;-))

Ciao, Mike
0
MadshiCommented:
Really!   :-)   (Ehm, of course I agree, too)

Regards, Madshi.
0
PeterLarsenCommented:
Last question of the week - have to make my self visible here every week :-)

Go home - its weekend :)
Peter
0
Alisher_NCommented:
looks like everybody just eager to grab new Q and answer it in few seconds...

;-)
0
zealsoftCommented:
Assume you store the file name in the szFile.

    hDateFile : HFILE;
    CreationTime, LastAccessTime, LastWriteTime: TFILETIME;
    SystemTime : TSYSTEMTIME;

     hDateFile := CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ,
          Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
      GetFileTime(hDateFile, @CreationTime, @LastAccessTime,
          @LastWriteTime);

      // Set Created time.
      FileTimeToLocalFileTime(CreationTime, CreationTime);
      FileTimeToSystemTime(CreationTime, SystemTime);
0
MadshiCommented:
Mike, how about posting an answer with 2 lines of code?    :-)

Regards, Madshi.
0
LischkeCommented:
:-/

procedure TMainForm.Button7Click(Sender: TObject);

var
  SR: TSearchRec;
  FileTime: TFileTime;
  SystemTime: TSystemTime;
  CreationDate: TDateTime;

begin
  if FindFirst('N:\Delphi\TOOLS\tnet32.dof', faAnyFile, SR) = 0 then
  begin
    FileTime := SR.FindData.ftCreationTime;
    FileTimeToSystemTime(FileTime, SystemTime);
    CreationDate := SystemTimeToDateTime(SystemTime);
    ShowMessage(DateTimeToStr(CreationDate));
  end;
end;

Pandian, it is very unpolite to reject an answer without given at least a simple description. Keep in mind: we do help you not vice versa!

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LischkeCommented:
Sorry, forgot the FindClose call right after ShowMessage (but within the begin/end block):

    FindClose(SR);


Ciao, Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.