![]() |
Verzeichnisgröße ermitteln
Delphi-Quellcode:
Gefunden in einem Beitrag von alexander. Ursprüngliche Quelle: SwissDelphiCenter.
function GetDirSize(dir: string; subdir: Boolean): Longint;
var rec: TSearchRec; found: Integer; begin Result := 0; if dir[Length(dir)] <> '\' then dir := dir + '\'; found := FindFirst(dir + '*.*', faAnyFile, rec); while found = 0 do begin Inc(Result, rec.Size); if (rec.Attr and faDirectory > 0) and (rec.Name <> '.') and (rec.Name <> '..') and (subdir = True) then Inc(Result, GetDirSize(dir + rec.Name, True)); found := FindNext(rec); end; FindClose(rec); end; procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption := FloatToStr(GetDirSize('e:\download', False) / Sqr(1024)) + ' MBytes'; label2.Caption := FloatToStr(GetDirSize('e:\download', True) / Sqr(1024)) + ' MBytes'; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:06 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-2025 by Thomas Breitkreuz