Solved

Get attributes and created  of Folder

Posted on 2004-10-12
2
161 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

20 Experts available now in Live!

Get 1:1 Help Now