Solved

Get attributes and created  of Folder

Posted on 2004-10-12
2
158 Views
Last Modified: 2010-04-05
Hello Experts.

 i know how get size of folder but don't know how get get attributes and created day of Folder, please teach me.
 Thanks.
0
Comment
Question by:z27
  • 2
2 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 12295723
Hi,

For creation datetime of a folder:

function GetFileCreated(const filename: string): TDateTime;
var sr:TSearchRec;
  SysTimeStruct: SYSTEMTIME;
  lft:_FILETIME;
begin
  Result:=0; // if the file won't be found
  if FindFirst(FileName,faAnyFile,sr) = 0 then
  begin
    if FileTimeToLocalFileTime(sr.FindData.ftCreationTime, lft) and
      FileTimeToSystemTime(lft, SysTimeStruct) then begin
      result := SystemTimeToDateTime(SysTimeStruct);
    end;
  end;
  FindClose(sr);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ShowMessage(FormatDateTime('dd.mm.yyyy hh:nn:ss', GetFileCreated('c:\temp')));
end;

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 12295876
For attributes:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if (GetFileAttributes(PChar(Edit1.Text)) and faReadOnly) > 0 then ShowMessage('ReadOnly');;
end;

Look TSearchRec description in Delphi help for other attribute constants like faHidden, etc..

Regards, Geo
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now