ClassMicrosoft.VisualBasic.FileSystem SyntaxDim result As Long = LOF(fileNumber)
DescriptionThe LOF function returns the size of an open file in bytes. Usage at a GlanceLOF works only on an open file; if you need to know the size of a file that isn't open, use the FileLen function. ExampleThe following example shows how to use the LOF function to prevent reading past the end of a file in binary mode: Dim oneChar As Char Dim fileID As Integer = FreeFile( ) FileOpen(fileID, "c:\data.txt", OpenMode.Binary, OpenAccess.Read) Do While (Loc(fileID) < LOF(fileID)) FileGet(fileID, oneChar) Console.WriteLine(Loc(fileID) & ": " & oneChar) Loop FileClose(fileID) Version DifferencesIn Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file-management features. See AlsoFileLen Function, FileOpen Procedure |