Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '########################################################
- ' Credits 3DotDev from http://3dotdevcoder.blogspot.fr/
- '########################################################
- Public Function BytestoString(ByVal Size As Long) As String
- Dim txt$ = String.Empty
- Try
- Dim i% = 1024
- Dim i1% = i * i
- Dim bl As Boolean = Size < CType(i, Long)
- If bl Then
- Return Size.ToString("D") & If(Size <= 1, " octet", " octets")
- Else
- Dim dbl As Double = CType(Size, Double) / CType(i, Double)
- bl = dbl < 1000
- If bl Then
- Return (CType(Size, Double) / CType(i, Double)).ToString("N") & " Ko"
- Else
- bl = dbl < 1000000
- If bl Then
- Return (CType(Size, Double) / CType(i1, Double)).ToString("N") & " Mo"
- Else
- bl = dbl < 30000000
- If bl Then
- Return ((CType(Size, Double) / CType(i1, Double)) / CType(i, Double)).ToString("N") & " Go"
- End If
- End If
- End If
- End If
- Catch ex As Exception
- txt = Size.ToString
- Return txt
- End Try
- Return txt
- End Function
- '############################# Comment l'utiliser ##############################
- Dim fi As New FileInfo("C:\Users\jm\Desktop\My 8 Files Uploader.exe")
- MsgBox(BytestoString(fi.Length.ToString))
- '##############################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement