You are here: Functions > FILESIZE()

FILESIZE()

FILESIZE() returns the file size in bytes for a PC-based file or returns the value 1 for zSeries server based files. If the file does not exist, the value -1 is returned.

Note: Filesize() is not intended for use on zSeries files because the zSeries operating system doesn’t support accessing the filesize of a file. As a result, Filesize() is only used on a zSeries file to test for the existence of the file.

Typically, this function is used to test for the existence of a file in order to control the execution of a procedure or to use the size returned for some useful calculation or comparison.

Function Format

FILESIZE(filename)

filename is the name of the file whose size or existence is to be determined.

For information on specifying a filename see Literal File Names.

Examples

To execute the procedure TEST only if the file Demo.dat exists:

DO TEST IF FILESIZE("Demo.dat")>0

In the Expression Builder, you can select FILESIZE() from the Functions drop-down list by double-clicking that item in the list.

The selected function is inserted in the Expression text box. If the file to be sized is not in the same directory, you must insert either a relative path or an absolute path for the file.

FILESIZE("c:\directory\subdirectory\Demo.dat")

To display the size of Demo.dat, in the Command Log use the Display command.

DISPLAY FILESIZE("Demo.dat")