1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Dim fileNames = My.Computer.FileSystem.GetFiles("C:\ProgramData\EmuWare\Temp\Extract\", FileIO.SearchOption.SearchTopLevelOnly, "*.*")
Dim info As System.IO.FileInfo
For Each file As String In fileNames
info = My.Computer.FileSystem.GetFileInfo(file)
'On prépare les données pour chaque colonne du datagrid
Dim str(3) As String
Dim itm As ListViewItem
str(0) = resultat
str(1) = ext
Dim CalculatedSize As Decimal
Dim TheSize As Long = Long.Parse(info.Length)
Dim typefichier As String = "B"
If TheSize < 1024 Then
CalculatedSize = TheSize
ElseIf TheSize > 1024 AndAlso TheSize < (1024 ^ 2) Then 'KB
CalculatedSize = Math.Round((TheSize / 1024), 2)
typefichier = "Kb"
ElseIf TheSize > (1024 ^ 2) AndAlso TheSize < (1024 ^ 3) Then 'MB
CalculatedSize = Math.Round((TheSize / (1024 ^ 2)), 2)
typefichier = "Mb"
ElseIf TheSize > (1024 ^ 3) AndAlso TheSize < (1024 ^ 4) Then 'GB
CalculatedSize = Math.Round((TheSize / (1024 ^ 3)), 2)
typefichier = "Gb"
ElseIf TheSize > (1024 ^ 4) Then 'TB
CalculatedSize = Math.Round((TheSize / (1024 ^ 4)), 2)
typefichier = "Tb"
End If
str(2) = CalculatedSize.ToString() + " " + typefichier |
Partager