Deleting a file (#FILE DELETE)

The command #FILE DELETE is used to delete a file. The parameter must be specified. Otherwise, a corresponding error message is generated.

Syntax:

#FILE DELETE [ PATH="<filename>" ]

PATH=
<filename>“

File to be deleted with directory specification.

The equals sign (=) is optional.

The user must have write authorisation to the PATH Directory to be able to delete a file.

Notice

WRITE PROTECTION:

If the file is write-protect5ed, the error is generated by ID 21627.

Notice

RELATIVE DIRECTORIES:

If the PATH parameter is specified as relative, a search is made for the file in the folders of the start-up/channel parameter list.

The search is for the sequence main program - subroutine - work directory.

In addition, the default directory for the file operation is used in TwinCAT. This setting is made in the System Manager.

Programming Example

Deleting a file

%FileDelete
N10 #FILE NAME[MSG="C:\Test.txt"] ;Create file
...
N40 #MSG SAVE["Write me into file"] ;Writes text to file
N60 #FILE DELETE[PATH="C:\Test.txt" ] ;Delete file
N70 M30