FileSystem.LOF(Int32) Method

Definition

Returns 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.

C#
public static long LOF(int FileNumber);

Parameters

FileNumber
Int32

Required. An integer that contains a valid file number.

Returns

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.

VB
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

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also