SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Code snippet - 0002

Latest post 04-19-2005 9:13 AM by ericwsw. 0 replies.
  • 04-19-2005 9:13 AM

    • ericwsw
    • Top 50 Contributor
    • Joined on 05-04-2004
    • Singapore
    • Posts 82

    Code snippet - 0002

    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