Version: 2
restore

Contents

Method

AppendText

ModuleFileContent
LibraryFileContent
Action

Append the supplied text to the specified file. If the file does not exist it is created using any specified encoding, and then the file is closed.

Parameters

FilePath (string; required): The full path of the file. The file will be created if it doesn't exist. Supports environment variables.

Text (string; required): The text string to be appended to an existing file or written to a new file.

Backup (bool; optional): Whether or not to backup the file prior to writing. If the file already exists, a copy of the file will be made in the same directory with the .bak suffix. If this backup file already exists, an incrementing int will be added after the extension. If a backup cannot be created, this method will return an error. Default is false.

NewLine (bool; optional) If true an OS specific line separator sequence will be written before the Text is written or appended.

Encoding (string, optional): File content encoding. Default is "UTF8NOBOM". Valid values are:

  • “ANSI”
  • “UTF8” – UTF8 with a byte order mark.
  • “UTF8NOBOM” – UTF8 without a byte order mark.
  • “UTF16LE” – UTF16 little endian byte order.
  • “UTF16BE” -UTF16 big endian byte order.
Return values

ExpandedFilePath (string): The file path of the written file, with any environment variables expanded.

Success (bool): Indicates whether the method succeeded.

BackupFileName (string): The full path of the backup file created if Backup is true. A NULL is returned if Backup is false.

Example

Append a sequence of text with line separators to file orwell.txt.

@lines = select 'The clock' as line union select ' struck ' as line union select "thirteen o'clock" as line;

FOREACH @line in @lines DO
    FileContent.AppendText(FilePath:"orwell.txt", Text:@line, NewLine: true);
DONE;
Platforms
  • Windows
  • Linux
  • MacOS
  • Solaris Intel
  • Solaris SPARC
Notes