FileLength64
PowerScript function
Description
Reports the length of a file of any size in bytes.
Syntax
|
1 |
FileLength64 ( filename ) |
|
Argument |
Description |
|---|---|
|
filename |
A string whose value is the name of the file for which you |
Return value
Longlong.
Returns the length in bytes of the file identified by filename. If
the file does not exist, FileLength64 returns -1. If filename is null,
FileLength64 returns null.
Usage
Call FileLength64 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 bytes at a time. Use the FileReadEx function to read
longer files.
The length returned by FileLength64 always includes the byte-order
mark (BOM). For example, suppose the hexadecimal display of the file
SomeFile.txt is FF FE 54 00 68 00 69 00 73 00, then the following
statement returns 10,which includes the BOM:
|
1 |
ll_length = FileLength64("SomeFile.txt") |
File security
If any security is set for the file (for example, if you are
sharing the file on a network), you must call FileLength64 before
FileOpen or after FileClose. Otherwise, you get a sharing
violation.
Examples
This statement returns the length of the file EMPLOYEE.DAT in the
current directory:
|
1 |
FileLength64("EMPLOYEE.DAT") |
These statements determine the length of the EMP.TXT file in the
EAST directory and open the file:
|
1 2 3 4 5 |
long LengthA integer li_FileNum LengthA = FileLength64("C:EASTEMP.TXT") li_FileNum = FileOpen("C:EASTEMP.TXT", & LineMode!, Read!, LockReadWrite!) |
The examples for FileRead illustrate reading files of different
lengths.
See also