Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Need hlp with directory size

  Alt 6. Jan 2013, 19:34
Delphi-Version: 2010
Delphi-Quellcode:
var
  Dir: string;
  Rec: TSearchRec;
begin
  Result := 0;

  Dir := IncludeTrailingPathDelimiter(ADirectory);
  if FindFirst(Dir + AMask, faAnyFile or faDirectory, Rec) = 0 then
  try
    repeat
      if (Rec.Attr and faDirectory) = faDirectory then
      begin
        if (Rec.Name <> '.') and (Rec.Name <> '..') then
          Result := Result + GetDirectorySize(Dir + Rec.Name)
        ;
      end
      else
        Result := Result + GetFileSize(Dir + Rec.Name);
      ;
    until FindNext(Rec) <> 0;
  finally
    FindClose(Rec);
  end;
end;
This is my function. It working well, when need to get complete folder size, but for example if I set mask to "*.mp4", it returns 0. Test folder contain 0 files and many folders, each one contain files (in each one is minimum 1 MP4 file). What's wrong with this code?
  Mit Zitat antworten Zitat