Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

All information about file - Files & folders - Tips & Tricks - Greatis Delphi Pages

TWin32FindData record contains information about type of file and ExtractFileDir, ExtractFileDrive, ExtractFileExt, ExtractFileName, ExtractFilePath procedures contain information about location of the file.


procedure TForm1.Button1Click(Sender: TObject);
var
  MyS: TWin32FindData;
  FName: string;
  MyTime: TFileTime;
  MySysTime: TSystemTime;
begin
  Memo1.Clear;
  FName:=Edit1.Text;
  with Memo1.Lines do
  begin
    Add('Directory - '+ExtractFileDir(FName));
    Add('Drive - '+ExtractFileDrive(FName));
    Add('Extension - '+ExtractFileExt(FName));
    Add('File name - '+ExtractFileName(FName));
    Add('Path - '+ExtractFilePath(FName));
    Add('');

    FindFirstFile(PChar(FName), MyS);
    case MyS.dwFileAttributes of
      FILE_ATTRIBUTE_COMPRESSED: Add('Attribute - File is compressed');
      FILE_ATTRIBUTE_HIDDEN: Add('Attribute - File is hidden');
      FILE_ATTRIBUTE_NORMAL: Add('Attribute - File has no any attributes');
      FILE_ATTRIBUTE_READONLY: Add('Attribute - Read only file');
      FILE_ATTRIBUTE_SYSTEM: Add('Attribute - System file');
      FILE_ATTRIBUTE_TEMPORARY: Add('Attribute - File for temporary storage');
      FILE_ATTRIBUTE_ARCHIVE: Add('Attribute - Archive file');
    end;

    MyTime:=MyS.ftCreationTime;
    FileTimeToSystemTime(MyTime, MySysTime);
    Add(
      'Time Creation - '+
      IntToStr(MySysTime.wDay)+'.'+
      IntToStr(MySysTime.wMonth)+'.'+
      IntToStr(MySysTime.wYear)+'  '+
      IntToStr(MySysTime.wHour)+':'+
      IntToStr(MySysTime.wMinute));

    MyTime:=MyS.ftLastAccessTime;
    FileTimeToSystemTime(MyTime, MySysTime);
    Add(
      'Last time access - '+
      IntToStr(MySysTime.wDay)+'.'+
      IntToStr(MySysTime.wMonth)+'.'+
      IntToStr(MySysTime.wYear));

    Add('Size - '+IntToStr(MyS.nFileSizeLow));
    Add('Alternate name - '+StrPas(MyS.cAlternateFileName));
  end;
end;
For more
Win32 programmer's reference

Download source