Thema: Delphi Brauche QFileCtrls.dcu

Einzelnen Beitrag anzeigen

julchen

Registriert seit: 20. Mär 2008
115 Beiträge
 
Delphi 10.3 Rio
 
#8

Re: Brauche QFileCtrls.dcu

  Alt 23. Jun 2008, 14:16
Lösung: Code von Joey *DClub* , DelphiLand
Delphi-Quellcode:
procedure CountFiles(FilePath: string);
var
  SearchRec: TSearchRec;
  Count: Integer;
begin
  Count := 0;
  if FilePath[Length(FilePath)] <> '\then FilePath := FilePath + '\';
  if FindFirst(FilePath + '*.*', faAnyFile and not faDirectory, SearchRec) = 0 then
  begin
    Inc(Count);
    while FindNext(SearchRec) = 0 do
    begin
      Inc(Count);
    end;
  end;

  FindClose(SearchRec);
  Form1.Label1.Caption := IntToStr(Count);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  CountFiles('C:\x\');
end;
  Mit Zitat antworten Zitat