GetFileSize

Obtains the size of a file and stores it in the specified variable.

Member of namespace

FileIO

Syntax

bool GetFileSize (string filename, string targetVariable)

Parameters

filename
Type: string
targetVariable
Type: string

Parameters

  • filename : The name and path of the file.
  • targetVariable : The name of the variable to store the file size. The variable level must be specified with a Smart Parameter.

Smart parameters are supported for each of the input parameters.

Returns

False if the target variable is blank. Otherwise, True.

Level

All levels.

Details

The size of the specified file will be stored into the specified variable. This can be helpful to test for problems, such as empty files. Subsequent actions can perform tests on the stored value and act upon it.

If the specified file is not found, the action will return True and a size of 0 will be stored into the variable. If any other kind of error occurs, the action will return False and the variable may or may not be set to 0.

Example
GetFileSize("C:\Temp\MyFile.txt", "@B.MyVariable")   

This example sets the file size in the variable MyVariableat the batch level.