Public Shared Function FormatFileSize(ByVal FileSizeBytes As Long) As String
Dim sizeTypes() As String = {"b", "Kb", "Mb", "Gb"}
Dim Len As Decimal = FileSizeBytes
Dim sizeType As Integer = 0
Do While Len > 1024
Len = Decimal.Round(Len / 1024, 2)
sizeType += 1
If sizeType >= sizeTypes.Length - 1 Then Exit Do
Loop
Dim Resp As String = Len.ToString & " " & sizeTypes(sizeType)
Return Resp
End Function
Komentarų nėra:
Rašyti komentarą