FileLen Function

See AlsoAFLB5E              ExampleMJRL3>Low

Returns a Long integer that indicates the length of a file in bytes.

Syntax

FileLen (filename)

Remarks

The argument filename can be any string expression1330R89 that contains an unambiguous (no wildcards) file specification.  The file specification may include optional drive and path information.

If the specified file is open when the FileLen function is called, the value returned represents the length of the file before it was opened.


See Also

FileDateTime Function28WTVSD

GetAttr FunctionZIM94C

LOF FunctionLANLOF


FileLen Function Example

The example uses FileLen to get file size information about a file.  File size information is displayed in a message box anytime you choose the name of a file in the file list box.  To try this example, paste the code into the Declarations section of a form containing a file list box named File1.  Then press F5 to start.

Sub File1_Click ()

   Dim Msg, TimeStamp                    ' Declare variables.

   FName = File1.FileName                ' Get selected file name.

   TimeStamp = FileDateTime(FName)       ' Get file date/time info.

   Msg = UCase(FName) & " was created or last modified on "

   Msg = Msg & Format(TimeStamp, "dddddd") & " at "

   Msg = Msg & Format(TimeStamp, "h:mm AM/PM") & ".  Its size is "

   Msg = Msg & FileLen(FName) & " bytes."      ' Get file size.

   MsgBox Msg                            ' Display message.

End Sub