LOF Function


LOF Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

     Dim result As Long = LOF(fileNumber) 


fileNumber (required; Integer)

Any valid file number of a file opened with FileOpen

Description

The LOF function returns the size of an open file in bytes.

Usage at a Glance

LOF works only on an open file; if you need to know the size of a file that isn't open, use the FileLen function.

Example

The 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 Differences

In Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file-management features.

See Also

FileLen Function, FileOpen Procedure




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net