| {\rtf1\ansi\ansicpg1252\deff0\deflang1044{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 Description:This code will get the filesize of any file. \par Returns:Returns the format filesize in Bytes, Kbs, MB/s or GB/s. \par \par \par Public Function FileSize(sFile As String) As String \par Dim sSize As Single \par \par If Len(Dir$(sFile$)) Then \par Open sFile$ For Binary As #1 \par sSize = LOF(1) \par Close #1 \par \par Select Case sSize \par Case 0 To 1023 \par FileSize = sSize & " Bytes" \par Case 1024 To 1048575 \par FileSize = Format(sSize / 1024#, "###0.00") & " KB" \par Case 1024# ^ 2 To 1043741824 \par FileSize = Format(sSize / 1024# ^ 2, "###0.00") & " MB" \par Case Is > 1043741824 \par FileSize = Format(sSize / 1024# ^ 3, "###0.00") & " GB" \par End Select \par End If \par End Function \par \par 'How to use this... \par 'MsgBox FileSize ("C:\\Blah.exe") \par } |
FileSize |
India web developer web development India | India web development company India ecommerce web developer