Procedure.l DirectorySize(ID.l, Directory.s)
Protected Size.l
If ExamineDirectory(ID, Directory, "*.*")
Repeat
Entry.l = NextDirectoryEntry()
If Entry = 1
Size + DirectoryEntrySize()
ElseIf Entry = 2
Name.s = DirectoryEntryName()
If Name <> ".." And Name <> "."
Size + DirectorySize(ID+1, Directory+Name+"\")
UseDirectory(ID)
EndIf
EndIf
Until Entry = 0
EndIf
ProcedureReturn Size
EndProcedure
; Use 0 as ID, it is only needed for the recursive calls
Debug DirectorySize(0, "C:\WINNT\")
Debug DirectorySize(0, "C:\Temp\")
But be aware that if you have many big files then the total size may be
reported incorrectly due to limitations in PureBasic... I had to remove such
a procedure from one of my apps, and am waiting for big number support
in PureBasic before putting it back in.