Write File

This action writes a new file or appends to an existing file.

Note that the file is only written during execution in Design mode in Design Studio, if the option Execute in Design Mode has been selected.

To test whether a given file exists, use the Test File Existence action.

If a CSV (Comma-Separated Value) file should be written, it can be done in two ways: Either write the file one line at a time with Write File, using an Add To CSV data converter to create each line. Alternatively, build up the desired file contents one line at a time in a global variable (again with the aid of the Add To CSV data converter) and use Write File in the end (that is, in an additional branch) to write the file in one piece.

To modify the global variable that holds the file contents, use the Assign Variable action that takes its input from a Get Variable data converter pointing to the variable itself. This is then followed by the Add To CSV data converter.

Properties

The Write File action can be configured using the following properties:

File Name

The name of the file. The name can be specified in several ways using the Value Selector. The name must be an absolute file name, including the drive name, if any, and the directory path to the file.

File Content

The contents to write to the file. The contents can be specified in several ways using the Value Selector. The contents can be either binary data or text. In the latter case, the character encoding selected in the File Encoding property will be used for encoding the text as bytes. See the Data Converters section for how to use converters to provide file contents for CSV, XML, and JSON files.

File Encoding

If the contents to write to the file is text, this property specifies the character encoding to use for encoding the text as bytes.

Append to File

Specifies whether a new file should always be created (overwriting any existing file with the same name), or whether the contents should be appended to the file if it already exists. Note that Append to File only adds new content at the end of an existing file, regardless of the file format. Therefore, this option should only be used with text variables.

Create Directories

Specifies whether to create the necessary directories on the file path before creating a new file. If not selected, then the action will fail if any directory on the path does not exist.

Execute in Design Mode

If this is enabled, the action will be executed even in Design Mode inside Design Studio. If this is disabled, the action will do nothing when you navigate the robot in Design Mode.