Рекурсивный проход дерева каталогов
Автор: Vit
WEB-сайт: http://forum.vingrad.ru
procedure ScanDir(Dir: string);
var
SearchRec: TSearchRec;
begin
if Dir <> '' then
if Dir[length(Dir)] <> '\' then
Dir := Dir + '\';
if FindFirst(Dir + '*.*', faAnyFile, SearchRec) = 0 then
repeat
if (SearchRec.name = '.') or (SearchRec.name = '..') then
continue;
if (SearchRec.Attr and faDirectory) <> 0 then
ScanDir(Dir + SearchRec.name)
//we found Directory: "Dir+SearchRec.name"
else
Showmessage(Dir + SearchRec.name);
//we found File: "Dir+SearchRec.name"
until
FindNext(SearchRec) <> 0;
FindClose(SearchRec);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ScanDir('c:');
end;
|