ob da nun while oder if steht ist suppe
while benutzte ich da das dann kürzer ist hier mit if
wo soll ich die zeile nocheinmal reinbauen?
Delphi-Quellcode:
function FindPath(ToBeFound, Path : string) : string;
var
ASearchRec : TSearchRec;
begin
Result := '';
if Path[Length(Path)] <> '\' then
Path := Path + '\';
if FindFirst(Path + '*.*', faDirectory, ASearchRec) = 0 then
begin
repeat
if ((ASearchRec.Attr and faDirectory) = faDirectory) and
(ASearchRec.Name <> '..') and
(ASearchRec.Name <> '.') then
begin
if CompareText(ToBeFound, ASearchRec.Name) = 0 then
begin
Unit1.Form1.ListBox1.Items.Add(BuildFileName(Path, ASearchRec.Name));
Result := BuildFileName(Path, ASearchRec.Name);
Break;
end
else
begin
FindPath(ToBeFound, BuildFileName(Path, ASearchRec.Name));
end;
end;
until FindNext(ASearchRec) <> 0;
FindClose(ASearchRec);
end;
end;