FileSystem.LOF Method (Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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.

Namespace:   Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static long LOF(
	int FileNumber
)

Parameters

FileNumber
Type: System.Int32

Required. An Integer that contains a valid file number.

Return Value

Type: System.Int64

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.

Exception Condition
IOException

FileNumber does not exist.

IOException

File mode is invalid.

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

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.

.NET Framework
Available since 1.1
Return to top
Show: