FileSystem.LOF(Int32) Method

Definition

Returns a Long representing the size, in bytes, of a file opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than LOF. For more information, see FileSystem.

public static long LOF (int FileNumber);
Parameters
FileNumber
Int32

Required. An Integer that contains a valid file number.

Returns

Returns a Long representing the size, in bytes, of a file opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than LOF.

Exceptions

File mode is invalid.

Examples

This example uses the LOF function to determine the size of an open file. This example assumes that TestFile is a text file that contains sample data.

Dim length As Long
FileOpen(1, "C:\TESTFILE.TXT", OpenMode.Input) ' Open file.
length = LOF(1)   ' Get length of file.
MsgBox(length)
FileClose(1)   ' Close file.

Remarks

Use the FileLen function to obtain the length of a file that is not open.

Applies to

See Also