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?