Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Edge HMI

FileWrite

  • Last UpdatedOct 29, 2026
  • 2 minute read

FileWrite is a built-in function that writes a string to a specified text file. If the file does not exist, it will be created when the function is executed.

Function

Group

Execution

String Exp.

Windows

Windows Embedded

IoT View

Thin Clients

Mobile Access

FileWrite

File

Synchronous

No

Supported

Supported

Supported

Executed on Server (see Notes below)

Supported

Syntax

FileWrite(strFileName,strWriteText,optNumAppend)

FileWrite ( strFileName , strWriteText { | ,optNumAppend } )

strFileName

The name of the text file.

By default, the file must be located in your project folder (that is, the folder that contains the file <project name>.APP), on the computer that host the project runtime server. If the file is or should be located in another folder, specify the complete file path.

Note: Follow the conventions of the target platform for the file path and name, and separators. For example, a file path in Windows starts with a drive letter and uses backward slashes as separators (C:\path\to\file), while a file path in Linux starts at the root directory and uses forward slashes as separators (/path/to/file).

strWriteText

The text to be written to the file.

optNumAppend

A numerical flag indicating how the text should be written to the file:

Value

Description

0

Create a new ASCII file with the specified file name. If the file already exists, overwrite it.

1

Append to an existing ASCII file with the specified file name. If the file does not exist, create it.

2

Create a new Unicode file (UTF-16LE on Windows, UTF-8 on Linux) with the specified file name. If the file already exists, overwrite it.

3

Append to an existing Unicode file (UTF-16LE on Windows, UTF-8 on Linux) with the specified file name. If the file does not exist, create it.

This parameter is optional; if no value is specified, or if the specified value is not one of the values listed in the table above, the default value is 0.

Returned value

This function returns one of the following possible values:

Value

Description

0

Function successfully executed.

-1

Invalid parameter(s).

-2

Failed to open file. Either the drive is write-protected or the file name is invalid.

Notes

By default, this function is executed on the project runtime server even when it is called in a screen on a project thin client, which means it only affects directories and files that are located on the server and all paths must be specified in that context. You can change the default behavior to force this function to be executed on the client where it is called, but if you do so, you must keep in mind that the change will affect not just this function but also several other File functions. To change the behavior of these functions, use a text editor to open your project file (<project name>.app) and then edit the following property:

[Options]

ExecuteFileFunctionsOnClient=1

Examples

Create a new ASCII file in the project folder:

FileWrite("est.txt","This is a test.")

Append to an existing ASCII file in the project folder:

FileWrite("est.txt","This is a test.",1)

Append to an existing Unicode file in the Documents folder:

FileWrite("C:\Users\MyUser\Documents\est.txt","This is a test.",3)

In This Topic
Related Links