Languages :: Delphi :: Knowledge Base : How to get a directory size in bytes ? Pascal or Delphi, Windows, DOS |
|||
| By: VGR |
Date: 21/03/2005 08:40:16 |
Points: 0 | Status: Answered Quality : Good |
|
Dated 06/06/2003 You may not need to include (uses clause) the Windows unit in source ; you need to adapt directory to come from a Directory choosing dialog, or simplier to be '.' so that the actual directory is used in stead. Program getsizedir(InPut,OutPut); {$APPTYPE CONSOLE} Uses SysUtils, Windows in 'H:\Borland\Delphi4\Source\Rtl\Win\windows.pas'; Var srec : TSearchRec; size : LongWord; Const directory = 'C:\pflash\*.*'; begin If FindFirst(directory,faAnyFile,srec)=0 Then Begin size:=0; Inc(size,srec.Size); While FindNext(srec)=0 Do Inc(size,srec.Size); SysUtils.FindClose(srec); WriteLn('size of ',directory,' is ',size,' bytes.'); End Else Writeln('Error accessing ',directory); ReadLn; end. |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








