Basic Univers
Procedure.l DirectorySize(dossier.s, filtre.s)
Dim DirectoryList.s(100)
Protected erreur.l
Protected Directory.l
Protected DirectorySize.l
erreur = 0
Directory = 1
DirectorySize = 0
If Right(dossier, 1) <> "\"
dossier = dossier + "\"
EndIf
Repeat
If ExamineDirectory(50, dossier, filtre)
Repeat
type.l = NextDirectoryEntry()
name.s = DirectoryEntryName()
If type = 1
NomFichier$ = dossier + name
DirectorySize = DirectorySize + FileSize(NomFichier$)
EndIf
If type = 2 And name <> "." And name <> ".."
Directory = Directory + 1
DirectoryList(Directory) = dossier + name + "\"
EndIf
Until type = 0
Else
erreur = 1
EndIf
For n = 1 To Directory
DirectoryList(n) = DirectoryList(n + 1)
Next
Directory = Directory - 1
SortArray(DirectoryList(), 2, 1, Directory)
dossier = DirectoryList(1)
Until Directory = 0
If erreur = 1
ProcedureReturn erreur
Else
ProcedureReturn DirectorySize
EndIf
EndProcedure
Procedure.s DisplaySize(size.l, unit.l, approximation.l, auto.l)
Protected val.l
Protected txt.s
If auto
approximation = 0 : unit = 0
If size >= 1000 : unit = 1 : approximation = 2 : EndIf
If size >= 10000 : unit = 1 : approximation = 1 : EndIf
If size >= 1000000 : unit = 2 : approximation = 2 : EndIf
If size >= 10000000 : unit = 2 : approximation = 1 : EndIf
EndIf
Select unit
Case 1 : val = 1024 : txt = " Ko"
Case 2 : val = 1024 * 1024 : txt = " Mo"
Default : val = 1 : txt = " octects"
EndSelect
ProcedureReturn StrF(size / val, approximation) + txt
EndProcedure
taille = directorysize("c:\zut\images", "*.*")
Debug taille
Debug displaysize(taille, 2, 2, 1)