Get file size up to a terabyte
Returns the file size of the file name passed in the format the user specifies
Inputs
File name, and return type (bytes, kilobytes, etc)
Returns
File size (double) in the format specified in the arguments
Side Effects
None to my knowledge
API Declarations
'Various views for file sizes
Public Enum FileSizeView
fsBytes = -1
fsKilobytes = 0
fsMegabytes = 1
fsGigabytes = 2
fsTerabytes = 3
End Enum
Rate Get file size up to a terabyte
(2(2 Vote))
Function FileSize(ByVal strFile As String, Optional ByVal ReturnAs As FileSizeView = fsBytes) As Double
'Purpose: Returns the file size of the file name passed in the format the user specifies
Dim dblLen As Double, lngIndex As Long
'If file doesn't exist, abort
If Dir(strFile) = Empty Then
FileSize = 0
Exit Function 'Abort
End If
'Returns the file length in bytes
dblLen = FileLen(strFile)
'Calculate to the file size view passed
For lngIndex = 0 To ReturnAs
dblLen = dblLen / 1024
Next
'Return the file size
FileSize = dblLen
End Function
Get file size up to a terabyte Comments
No comments yet — be the first to post one!
Post a Comment