Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get the time stamp of a directory Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
25-Oct-02
Category
Files Operation
Language
Delphi All Versions
Views
114
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to get the time stamp of a directory

Answer:

Solve 1:

1   program Project1;
2   
3   uses
4     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
5   
6   function GetTimeStamp(Directory: string): TDateTime;
7   var
8     Search: TSearchRec;
9   begin
10    Result := 0;
11    if FindFirst(Directory + '.', faDirectory, Search) = 0 then
12    begin
13      Result := FileDateToDateTime(Search.Time);
14    end
15    else
16      MessageDlg('Directory doesnt exist', mtWarning, [mbOK], 0);
17    FindClose(Search);
18  end;
19  
20  begin
21    MessageDlg('Folder Create Date: ' + DateTimeToStr(GetTimeStamp('c:\temp\')),
22      mtWarning, [mbOK], 0);
23  end.



Solve 2:

24  function FileTimeToDateTime(FileTime: TFileTime): TDateTime;
25  var
26    LocalFileTime: TFileTime;
27    SystemTime: TSystemTime;
28  begin
29    FileTimeToLocalFileTime(FileTime, LocalFileTime);
30    FileTimeToSystemTime(LocalFileTime, SystemTime);
31    Result := SystemTimeToDateTime(SystemTime);
32  end;
33  
34  procedure TForm1.Button1Click(Sender: TObject);
35  var
36    FSearchRec: TSearchRec;
37    DirDate: TDateTime;
38  begin
39    FindFirst('C:\Temp', faDirectory, FSearchRec);
40    DirDate := FileTimeToDateTime(FSearchRec.FindData.ftCreationTime);
41    ShowMessage(DateTimeToStr(DirDate));
42  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC