01-12-15, 08:21 PM
تفضل اخى
كود :
Dim CalculatedSize As Decimal
Dim TheSize As Long = Long.Parse(My.Computer.FileSystem.GetFileInfo("E:\Music\New folder\Avril Lavigne - I Love You [Goodbye lullaby] - YouTube.mp3").Length)
Dim SizeType As String = "B"
If TheSize < 1024 Then
CalculatedSize = TheSize
ElseIf TheSize > 1024 AndAlso TheSize < (1024 ^ 2) Then 'KB
CalculatedSize = Math.Round((TheSize / 1024), 2)
SizeType = "KB"
ElseIf TheSize > (1024 ^ 2) AndAlso TheSize < (1024 ^ 3) Then 'MB
CalculatedSize = Math.Round((TheSize / (1024 ^ 2)), 2)
SizeType = "MB"
ElseIf TheSize > (1024 ^ 3) AndAlso TheSize < (1024 ^ 4) Then 'GB
CalculatedSize = Math.Round((TheSize / (1024 ^ 3)), 2)
SizeType = "GB"
ElseIf TheSize > (1024 ^ 4) Then 'TB
CalculatedSize = Math.Round((TheSize / (1024 ^ 4)), 2)
SizeType = "TB"
End If
MessageBox.Show("File size is: " & CalculatedSize.ToString & " " & SizeType, "File size", MessageBoxButtons.OK, MessageBoxIcon.Information)

