1. Computing

Reading a directory content

By

The following example lists all files and subdirectories of the C:\Windows directory into a TListBox called ListBox1:

FindAll('C:\Windows\*.*',faAnyFile,ListBox1.Items)

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure FindAll (const Path: String;
                          Attr: Integer;
                          List: TStrings) ;
var
   Res: TSearchRec;
   EOFound: Boolean;
begin
   EOFound:= False;
   if FindFirst(Path, Attr, Res) < 0 then
     exit
   else
     while not EOFound do begin
       List.Add(Res.Name) ;
       EOFound:= FindNext(Res) <> 0;
     end;
   FindClose(Res) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» ToolTip Font Hint Properties
« Get File 'Last Modified' attribute

©2014 About.com. All rights reserved.