CopyFileTo

TwinCAT TIA
Local File and directory access File

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

The command copies an existing file to a specified path. If the specified file already exists, an error is output.

Parameters:

Returns:

Examples:

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

Beckhoff parameter:

    bFileAccessCopyFileTo
    A boolean variable that can be used to trigger the execution of the CopyFileTo command.
    OutputDataFileAccessCopyFileTo
    An instance of "ST_VoidOutputData" into which the return value of the CopyFileTo method is written.
    hrFileAccessCopyFileTo
    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 source file.
    sfullPathDestinationFile
    A STRING variable containing the full path of the destination file.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bFileAccessCopyFileTo        : BOOL;
     OutputDataFileAccessCopyFileTo      : ST_VoidOutputData;
     hrFileAccessCopyFileTo        : HRESULT;

     fbFileAccess  : FB_FileAccess;
END_VAR

hrFileAccessCopyFileTo := fbFileAccess.CopyFileTo(
          bExecute     := bFileAccessCopyFileTo,   
          ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
          sfullPathSourceFile  := 'C:\Test\text.txt',
          sfullPathDestinationFile:= 'C:\Test2\text.txt',
          OutputData    => OutputDataFileAccessCopyFileTo);
IF hrFileAccessCopyFileTo <> S_FALSE THEN 
     bFileAccessCopyFileTo := 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".