fileLength

fileLength(): Integer;

The fileLength method of the File class returns the size of the file (in file units). Use this method to test for an empty file. When the fileLength method is called for a file that is not open, the following occurs.

For Unicode text, the file unit is character (not byte). For Unicode text files that contain a Unicode File Marker, the file marker specified in the unicodeBOM property is ignored.

To find the length of a Unicode file in bytes instead of file units, open the file specifying the kind property of the file as Kind_Binary.

The code fragment in the following example shows the use of the fileLength method.

if (cmdFile.open = 0) then
    fileName      := cmdFile.fileName;
    create file;
    file.kind     := File.Kind_Binary;
    file.mode     := File.Mode_Input;
    file.fileName := fileName;
    photo         := file.readBinary(file.fileLength);
endif;

If the length of the file is greater than 2G byte file units, use the fileLength64 method to retrieve the length of the file (in file units).