| Scalabium Software | |
| Knowledge for your independence'. | |
|  Home  Delphi and C++Builder
        tips | 
| #118: How can I receive a number of files in some folder? | 
| 
 | Today I want to post tip with small function which allow to calculate a number of files in a specified directory. function GetFilesCount(Folder, WildCard: string): Integer;
var
  intFound: Integer;
  SearchRec: TSearchRec;
begin
  Result := 0;
  if (Folder <> '') and (Folder[Length(Folder)] <> '\') then
    Folder := Folder + '\';
  intFound := FindFirst(Folder + WildCard, faAnyFile, SearchRec);
  while (intFound = 0) do
  begin
    if not (SearchRec.Attr and faDirectory = faDirectory) then
      Inc(Result);
    intFound := FindNext(SearchRec);
  end;
  FindClose(SearchRec);
end;
To use: 
 | 
 | 
|       | Copyright© 1998-2025, Scalabium
        Software. All rights reserved. |