troubleshooting Question

Fill a list from a dir.

Avatar of jurgentje
jurgentje asked on
Delphi
17 Comments1 Solution183 ViewsLast Modified:
'Folder' is a dir like c:\windows
's1' is TListBox.Items
this is the code to fill the listbox with ALL the file op the directory 'folder'

---
procedure TForm1.FillFileList(Folder: string; sl: TStrings);
var Rec : TSearchRec;
begin
 sl.Clear;
 if SysUtils.FindFirst(Folder + '*.*', faAnyFile, Rec) = 0 then
  try
    repeat
      sl.Add(Rec.Name);
    until SysUtils.FindNext(Rec) <> 0;
  finally
    SysUtils.FindClose(Rec);
  end;
end;
---
This code adds only the files from c:\windows.
How can I change the code to add also ALL the sub-directories en sub-files?
ASKER CERTIFIED SOLUTION
ILE

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros