SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Code snippet - 0002

This post has 0 Replies | 0 Followers

Top 50 Contributor
Posts 82
ericwsw Posted: 04-19-2005 9:13 AM

Directory and File Info

Format the file size to bytes, KB or MB

Public Function FormatSize(ByVal RawData As Long) As String
        If RawData > 1048576 Then
            Return Format(RawData / 1048576, "#.## MB")
        End If
        If RawData > 1024 Then
            Return CStr(RawData \ 1024) + " KB"
        End If
        Return CStr(RawData) + " bytes"
End Function

Implementation

Dim fs As System.IO.Stream

fs = myDialog.OpenFile()
Me.lblSize.Text = FormatSize(fs.Length)

Page 1 of 1 (1 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems