FileSystem.file

New in package 167

Syntax

FileSystem.file( location[, options ] );

Description

Creates a File object representing the specified file.

Parameters

Parameter Type Description
location String or Directory File path or parent directory, see options.name below. Predefined {Temp} location implies options.temporary.
options.name String File name; if specified, location is interpreted as a parent directory path; required if location is a Directory.
options.create Boolean Create a new file. Fails if the file exists unless one of the additional create options below is specified.
options.text Boolean The file is created or opened in a text mode.

create options

options.append Boolean Append the new content to the existing file, if any.
options.overwrite Boolean Overwrite an existing file, if any.
options.unique Boolean Append a unique suffix to the name if the destination file already exists.
options.temporary Boolean Temporary files are deleted automatically; implies unique.

text options

options.encoding String Override the default encoding.

Examples

Create a text file:

Append the result of an Http request to the file:

Create a unique temporary file:

New in package 168 since Server Installer 168.0.10961

Create a unique file named with Time.timestamp in ISO 8601 basic format yyyyMMddTHHmmss.fffZ (e.g. 20150519T150338.622Z):

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.