hanonymouss
Gebruiker
- Lid geworden
- 7 sep 2011
- Berichten
- 283
Hallo allemaal
Ik heb deze code gebruikt om de grootte van de folder weer te geven in MB
[CPP] Private Function DirectorySize(ByVal dInfo As DirectoryInfo, _
ByVal includeSubDir As Boolean) As Long
Dim totalSize As Long = dInfo.EnumerateFiles() _
.Sum(Function(file) file.Length)
If includeSubDir Then
totalSize += dInfo.EnumerateDirectories() _
.Sum(Function(dir) DirectorySize(dir, True))
End If
Return totalSize
End Function
[/CPP]
[CPP] Dim dInfo As New DirectoryInfo("c:\test\")
Dim sizeOfDir As Long = DirectorySize(dInfo, True)
MsgBox("bestands grootte in MB : " & _
"{0:N2} MB", (CDbl(sizeOfDir)) / (1024 * 1024))
[/CPP]
Als ik het debug dan krijg ik zoiets ( MsgBox("bestands grootte in MB : {0:N2} MB
dit werkt dan wel in een console
Ik heb deze code gebruikt om de grootte van de folder weer te geven in MB
[CPP] Private Function DirectorySize(ByVal dInfo As DirectoryInfo, _
ByVal includeSubDir As Boolean) As Long
Dim totalSize As Long = dInfo.EnumerateFiles() _
.Sum(Function(file) file.Length)
If includeSubDir Then
totalSize += dInfo.EnumerateDirectories() _
.Sum(Function(dir) DirectorySize(dir, True))
End If
Return totalSize
End Function
[/CPP]
[CPP] Dim dInfo As New DirectoryInfo("c:\test\")
Dim sizeOfDir As Long = DirectorySize(dInfo, True)
MsgBox("bestands grootte in MB : " & _
"{0:N2} MB", (CDbl(sizeOfDir)) / (1024 * 1024))
[/CPP]
Als ik het debug dan krijg ik zoiets ( MsgBox("bestands grootte in MB : {0:N2} MB
dit werkt dan wel in een console