DeleteFile

TwinCAT TIA
Local File and directory access File

ns=2;s=DEPRAG Smart/Local/FileAndDirectoryAccess/FileAccess/DeleteFile

The command deletes the file in the specified path.

Parameters:

    FullPath
    Path of the file. The file can be either a local file or a file stored on a network drive.

Returns:

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bFileAccessDeleteFile
    A boolean variable that can be used to trigger the execution of the DeleteFile command.
    OutputDataFileAccessDeleteFile
    An instance of "ST_VoidOutputData" in which the return value of the DeleteFile method is written.
    hrFileAccessDeleteFile
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbFileAccess
    An instance of the "FB_FileAccess" function block supplied with the DEPRAG Smart library.
    sfullPathSourceFile
    A STRING variable containing the full path of the file.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bFileAccessDeleteFile        : BOOL;
     OutputDataFileAccessDeleteFile      : ST_VoidOutputData;
     hrFileAccessDeleteFile        : HRESULT;

     fbFileAccess  : FB_FileAccess;
END_VAR

hrFileAccessDeleteFile := fbFileAccess.DeleteFile(
           bExecute     := bFileAccessDeleteFile,   
           ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
           sfullPathSourceFile  := 'C:\Test2\text.txt',
           OutputData    => OutputDataFileAccessDeleteFile);
IF hrFileAccessDeleteFile <> S_FALSE THEN 
     bFileAccessDeleteFile := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".