'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?
just the ide instead of use faanyfile try $FFFF or $FF
just curious what will be happend
replace fanayfile with $ff and try with $FFFF
jurgentje
ASKER
if (rec.attr=17) or (rec.attr=18) then
this code works
OneSurfer
uses
FileCtrl
var S: String;
Rec: TSearchRec;
begin
If SelectDirectory('Select Some Directory','',S) then
If FindFirst(S+'\*.MP3', 0 , Rec) = 0 then with
ListBox1.Items do begin
BeginUpdate;
Repeat
Add(S+'\'+Rec.Name);
Until FindNext(Rec) <> 0;
Endupdate;
end;
{This gives complete path and file name, or just the file name(without the var)If anything, this shows a very simple way to get the Windows select directory dialog. Note: Adds about 700 pathitems in about three secs on older machine and Windows 2000}
but the dir is not the c:\idapi
but c:\windows\