Итерация подкаталогов
|
Комп, как модель матриархата: на одной мамке можно завести папок сколько влезет.
|
procedure TFormList.RecurseDir(PathInicial: string);
var
SearchRec: TSearchRec;
Result: integer;
tmpName: string;
begin
DirectoryListBox1.Directory := PathInicial;
Result := FindFirst(PathInicial + '\*.*', faAnyFile, SearchRec);
while Result = 0 do
begin
if ExtOk(SearchRec.Name) then
{ если каталог... }
if SearchRec.Attr and faDirectory > 0 then
{ рекурсивно обрабатываем... }
RecurseDir(PathInicial + '\' + SearchRec.Name)
else
begin
tmpName := PathInicial + '\' + SearchRec.Name;
tmpName := Copy(tmpName,
Pos(PathOrigen, tmpName) + Length(PathOrigen),
Length(tmpName) - Length(PathOrigen));
ListBox1.Items.Add(LowerCase(tmpName));
end;
Application.ProcessMessages;
Result := FindNext(SearchRec);
end;
DirectoryListBox1.Directory := PathInicial;
end;
|
|