![]() |
Delphi-Version: 2010
Need hlp with directory size
Delphi-Quellcode:
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?
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; |
AW: Need hlp with directory size
I suppose the directories do not end on ".mp4", so your mask does not match.
|
Re: Need hlp with directory size
You are correct. I know. But how (where) to apply this mask?
|
AW: Need hlp with directory size
You should set the internally used mask to *.* and check the search result to the mask of interest. I wrote a component which does it this way, in case of interest you can find it on
![]() |
Re: Need hlp with directory size
Nice component, I glanced on it, found what I needed and, yeah, I did it! :D
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:02 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz