VB.Net:
Dim CalculatedSize As Decimal
Dim TheSize As Long = Long.Parse(My.Computer.FileSystem.GetFileInfo("Dosyanın Konumu").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("Dosya Boyutu " & CalculatedSize.ToString & " " & SizeType, MessageBoxButtons.OK, MessageBoxIcon.Information)