CopyFileToWithOverwriteParameter

TwinCAT TIA
Local File and directory access File

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

The command copies an existing file to a specified path. If the specified file already exists, it can be overwritten.

Parameters:

    Overwrite
    The boolean variable specifies whether the destination file may be overwritten.

Returns:

Examples:

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

Beckhoff parameter:

    bFileAccessCopyFileToWithOverwriteParameter
    A boolean variable that can be used to trigger the execution of the CopyFileToWithOverwriteParameter command.
    OutputDataFileAccessCopyFileToWithOverwriteParameter
    An instance of the "ST_VoidOutputData" to which the return value of the CopyFileToWithOverwriteParameter method is written.
    hrFileAccessCopyFileToWithOverwriteParameter
    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.
    bOverwrite
    The boolean variable specifies whether the destination file may be overwritten.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bFileAccessCopyFileToWithOverwriteParameter   : BOOL;
     OutputDataFileAccessCopyFileToWithOverwriteParameter: ST_VoidOutputData;
     hrFileAccessCopyFileToWithOverwriteParameter  : HRESULT;

     fbFileAccess  : FB_FileAccess;
END_VAR

hrFileAccessCopyFileToWithOverwriteParameter := fbFileAccess.CopyFileWithOverwrite(
                bExecute     := bFileAccessCopyFileToWithOverwriteParameter,   
                ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
                sfullPathSourceFile  := 'C:\Test\text.txt',
                sfullPathDestinationFile:= 'C:\Test2\text.txt',
                bOverwrite    := TRUE,
                OutputData    => OutputDataFileAccessCopyFileToWithOverwriteParameter);
IF hrFileAccessCopyFileToWithOverwriteParameter <> S_FALSE THEN 
     bFileAccessCopyFileToWithOverwriteParameter := 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".