Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack Special Offer!


Share this page

Follow us
LinkedIn Blogspot Twitter Facebook

Related products
Ultimate Pack  hot!
iGrid Plotter  new!
Image Editor
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
Print Suite .NET
Gradient Controls .NET  new!

Related links
Win32.hlp online version
MegaDetailed.NET
Delphi to C#

Special
Free Software Promotion
Offers for Resellers

Hobby projects
cdtrrracks.com
books.storrre.com
in3steps.com
sovietphillumeny.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