Frage:
Wo sollte das "FindClose(SR)" stehen?
An Stelle (1) oder Stelle (2)?
Lese von einem Startverzeichnis "myDrivePath" alle gefundenen
Verzeichnisse und Dateien in eine ListBox "myListBox".
Delphi-Quellcode:
procedure TForm1._update(myDrivePath: s_250;
out myListBox: TListBox;
var retCntDirs,
retCntFiles : integer;
var retTotalBytes : cardinal);
{-} procedure _readDP(myDP: s_250);
var SR : TSearchRec;
begin
if (FindFirst(myDP+'*.*', faANYFILE, SR) = 0) then begin
repeat if ((SR.Attr and faDirectory) = faDirectory) then begin
{-found a dir, skip dirnames "." and ".."-}
if ((SR.Name = '.') or (SR.Name = '..')) then else begin
inc(retCntDirs);
myListBox.Items.Add(myDP+SR.Name+'\');
_readDP(myDP+SR.Name+'\');
end;
end else begin
{-found a file-}
inc(retCntFiles);
retTotalBytes:=retTotalBytes+SR.Size;
myListBox.Items.Add(myDP+SR.Name);
end;
until (FindNext(SR) <> 0);
{-1-} FindClose(SR);
end;
{-2-} FindClose(SR);
{-} end;
begin
myListBox.Items.Clear;
myListBox.Items.BeginUpdate;
if (AnsiLastChar(myDrivePath) <> '\') then myDrivePath:=myDrivePath+'\';
retCntDirs:=0; retCntFiles:=0; retTotalBytes:=0;
_readDP(myDrivePath);
myListBox.Items.EndUpdate;
end;
Gruss Terence