FileLength

Description

Reports the length of a file whose size does not exceed 2GB in bytes.

Syntax

FileLength ( filename )

Argument

Description

filename

A string whose value is the name of the file for which you want to know the length. If filename is not on the current application library search path, you must specify the fully qualified name.

Returns

Long. Returns the length in bytes of the file identified by filename. If the file does not exist, FileLength returns -1. If filename is null, FileLength returns null.

Usage

Call FileLength before or after you call FileOpen to check the length of a file before you call FileRead. The FileRead function can read a maximum of 32,765 characters at a time.

NoteFile security If any security is set for the file (for example, if you are sharing the file on a network), you must call FileLength before FileOpen or after FileClose. Otherwise, you get a sharing violation.

The FileLength function cannot return the length of files whose size exceeds 2GB.

Examples

Example 1

This statement returns the length of the file EMPLOYEE.DAT in the current directory:

FileLength("EMPLOYEE.DAT")

Example 2

These statements determine the length of the EMP.TXT file in the EAST directory and open the file:

long LengthA

integer li_FileNum

LengthA = FileLength("C:\EAST\EMP.TXT")

li_FileNum = FileOpen("C:\EAST\EMP.TXT", &

		StreamMode!, Read!, LockReadWrite!)

See also