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:
' http://www.stefanthoolen.nl/archive/vb6-functions/
' 
' You may freely distribute this file but please leave all comments, including this one, in it.
' 
' @Author Stefan Thoolen <mail@stefanthoolen.nl>

Option Explicit

''
' Gets file size
' Same syntax as the PHP function 'filesize'
' See also: http://www.php.net/manual/en/function.filesize.php
' @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 <mail@stefanthoolen.nl>
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