-

FILE_REMOVE

Type Function block
Description Deletes a file with a specific name.

Before deletion, the file to be deleted must be closed using the FILE_CLOSE function block.

Assign a STRING variable containing the name of the file to be deleted to the NAME input.

Activate the function block on a rising edge at the Execute input. Execution of the function block is complete when the Done output is set to 1. If an error occurred during execution, the value at the Error output = 1. ErrorID indicates the number of the cause of the error.
Notes
  • The file to be removed must not be write-protected, because files are always opened with read and write access rights.
  • The data type of the file name must be STRING. The length of the file name must not exceed 80 characters including the path. User-defined strings are not allowed.

    With PLCnext Technology controllers, the default file path is /opt/plcnext. Because this folder is write-protected on all secure-by-default controllers (for example, Virtual PLCnext Control, AXC F 1252 controller), file names without path are not recommended. If a file name without path information is used for a secure-by-default controller, the Error output indicates the error and the ErrorID output provides the error number 21 (see ErrorID output below).

    As of firmware version 2025.0, both device classes (PLCnext Technology controllers and secure-by-default controllers) contain a folder /opt/plcnext/custom to which the firmware has write access.

    For a complete list of secure-by-default controllers, refer to the PLCnext Info Center.

  • The status of the Done, Error, and ErrorID outputs are maintained until a falling edge is detected at the Execute input.
  • The error behavior of the function block may differ depending on the system on which the application with the function block call is running. If the function block is called for a file that is already open, the behavior may be as follows:
    • The file was not deleted. As expected, the Error output is set to TRUE and the ErrorID output issues error number 21.

      Or

    • The file was deleted (no error is reported). The file handle is still valid.
  • Function blocks have to be instantiated. The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used. The instance name must be unique within the POU.
Parameters Inputs

Execute

Name

Outputs

Done

Error

ErrorID