Hola.
Código Delphi
[-]
var
TotalFiles,TotalFolders: LongInt;
procedure TotalFilesFolders(Path:string);
var
SR: TSearchRec;
begin
ChDir(Path);
if FindFirst ('*.*', faDirectory, SR )=0 then
repeat
if ((SR.Attr and fadirectory) = fadirectory) then
begin
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
Inc(TotalFolders);
TotalFilesFolders(Path + '\' + SR.Name );
end
end
else
Inc(TotalFiles);
until FindNext(SR) <> 0;
FindClose( SR );
end;
Llamada ejemplo:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
TotalFiles:= 0;
TotalFolders:= 0;
TotalFilesFolders('C:\');
ShowMessage(Format('Archivos: %d Carpetas: %d',[TotalFiles,TotalFolders]));
end;
Un saludo.