1. Home
  2. Computing & Technology
  3. Delphi Programming

Reading a directory content

By , About.com Guide

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

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 1999 Delphi Tips
  7. Reading a directory content

©2009 About.com, a part of The New York Times Company.

All rights reserved.