Hi eJan, try with my code:
Code: Select all
Global TotalSize.q
Procedure.s Convert(byte.q, NbDecimals.l=2)
If byte < 1024
If byte < 0
byte=0
EndIf
ProcedureReturn ReplaceString(Str(byte)+" Byte", ".", ",")
ElseIf byte >= 1<<60
ProcedureReturn ReplaceString(StrD(byte/1<<60, NbDecimals)+" EB", ".", ",")
ElseIf byte >= 1<<50
ProcedureReturn ReplaceString(StrD(byte/1<<50, NbDecimals)+" PB", ".", ",")
ElseIf byte >= 1<<40
ProcedureReturn ReplaceString(StrD(byte/1<<40, NbDecimals)+" TB", ".", ",")
ElseIf byte >= 1<<30
ProcedureReturn ReplaceString(StrD(byte/1<<30, NbDecimals)+" GB", ".", ",")
ElseIf byte >= 1<<20
ProcedureReturn ReplaceString(StrD(byte/1<<20, NbDecimals)+" MB", ".", ",")
Else
ProcedureReturn ReplaceString(StrD(byte/1024, NbDecimals)+" KB", ".", ",")
EndIf
EndProcedure
Procedure.s GetSpecialFolder(CSIDL.l)
Protected *itemid.ITEMIDLIST
Protected location.s = Space(#MAX_PATH)
If SHGetSpecialFolderLocation_ (0, CSIDL, @*itemid) = #NOERROR
If SHGetPathFromIDList_(*itemid, @location)
If Right(location, 1) <> "\" : location + "\" : EndIf
ProcedureReturn location
EndIf
EndIf
EndProcedure
path$ = GetSpecialFolder(#CSIDL_PROGRAMS)
Procedure.q GET_CSIDL_PROGRAMS(path$,pattern$ = "*.*")
If Right(path$,1)<>"\":path$+"\":EndIf
DirID = ExamineDirectory(#PB_Any,path$,pattern$)
If DirID
While NextDirectoryEntry(DirID)
If DirectoryEntryType(DirID) = #PB_DirectoryEntry_Directory
If DirectoryEntryName(DirID)<>"." And DirectoryEntryName(DirID)<>".."
GET_CSIDL_PROGRAMS(path$+DirectoryEntryName(DirID)+"\",pattern$)
Debug DirectoryEntryName(DirID) + " = "+ Convert(TotalSize.q)
EndIf
EndIf
If DirectoryEntryType(DirID) = #PB_DirectoryEntry_File
TotalSize.q + DirectoryEntrySize(DirID)
EndIf
Wend
FinishDirectory(DirID)
EndIf
ProcedureReturn TotalSize.q
EndProcedure
GET_CSIDL_PROGRAMS(path$,"*.*")
Regards
