Visual Basic 6 function "filesize"

Go back

Below you'll find the source for the Visual Basic 6 function filesize.

Attribute VB_Name = "modFilesize"
' This function is downloaded from:
' You may freely distribute this file but please leave all comments, including this one, in it.
' @Author Stefan Thoolen <>

Option Explicit

' Gets file size
' Same syntax as the PHP function 'filesize'
' See also:
' @param    String  filename        The file of which we want to know the size
' @return   Long                    The size of the file in bytes
' @author   Stefan Thoolen <>
Public Function filesize(filename As String) As Long
    Dim ff As Integer
    ff = FreeFile
    Open filename For Binary Access Read Shared As #ff
        filesize = LOF(ff)
    Close #ff
End Function