Chciałem właśnie użyć gotowca z algorytmów, który tworzy spis katalogów w wybranym katalogu.. i cosik nie chce działać.. :-/
Procedura szukająca katalogi:
procedure TForm1.SearchDir(StartPath: String);
var
SR: TSearchRec;
Found : Integer;
function IsDir(Value : String) : String;
begin
if Value[Length(Value)] <> '\\' then
Result := Value + '\\' else Result := Value;
end;
begin
Found := FindFirst(IsDir(StartPath) + '*.*', faDirectory, SR);
while Found = 0 do
begin
Application.ProcessMessages;
if ((SR.Attr and faDirectory) = faDirectory) and
((SR.Name <> '.') and (SR.Name <> '..')) then
begin
Writeln(t,IsDir(StartPath) + SR.Name);
SearchDir(IsDir(StartPath) + SR.Name);
end;
Found := FindNext(SR);
end;
FindClose(SR);
end;
Przykładowe wywołanie:
procedure TForm1.Button1Click(Sender: TObject);
begin
AssignFile(t, 'c:/spis.txt');
rewrite(t);
SearchDir('D:\Others\MP3');
closefile(t);
end;
Plik spis.txt oczywiście się tworzy, ale jest niestety pusty... - nie wiem co jest źle ...