JavaScript global method: readFile

Reads data from the file system on the ITSMA Service Management server host.

Syntax

readFile( path, binary );

Arguments

The following arguments are valid for this function:

Argument Data type Required Description
path String Yes This parameter contains the text string or variable value containing the fully qualified path of the file to be read. You must enclose literal text strings in quotation marks.
binary String Yes This parameter determines if the file format is binary or text. Use the string "b" or "B" to read a binary file. Use any other value to read a text file.

Return values

A string object containing the contents of the file.

Description

This method reads the contents of a local file and returns a string object. The file can be in binary format or text format as determined by the binary argument.

Example

This example does the following:

  • Reads the contents of a text file
  • Reads the contents of a binary file

This example requires the following sample data:

  • A text file on the local file system
  • A binary file on the local file system
var textFile = readFile( "C:\\test.xml", "t" );
print( "The value of textFile is: " + textFile );

var binFile = readFile( "C:\\header_left.gif", "b" );
print( "The value of binFile is: " + binFile );