GetFileInfo

TwinCAT TIA
Local File and directory access File

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

The command returns the file properties of the specified file.

Parameters:

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

Returns:

    GetFileInfo
    A variable of the OpcMethodReturnValueFileInfo type. The Result property contains the command-specific return values.
      Result
      A variable of type FileInfo. This contains all properties of the file.
        Attributes
        An enumeration with the attributes of the file.
        The enumeration can have the following attributes. The attributes can also occur in combination.
        ReadOnly = 1
        Hidden = 2
        System = 4
        Directory = 16
        Archive = 32
        Device = 64
        Normal = 128
        Temporary = 256
        SparseFile = 512
        ReparsePoint = 1024
        Compressed = 2048
        Offline = 4096
        NotContentIndexed = 8192
        Encrypted = 16384
        IntegrityStream = 32768
        NoScrubData = 131072
        Directory
        A variable of type DirectoryInfo. This contains properties of the parent folder.
          Attributes
          An enumeration with the attributes of the file.
          The enumeration can have the following attributes. The attributes can also occur in combination.
          ReadOnly = 1
          Hidden = 2
          System = 4
          Directory = 16
          Archive = 32
          Device = 64
          Normal = 128
          Temporary = 256
          SparseFile = 512
          ReparsePoint = 1024
          Compressed = 2048
          Offline = 4096
          NotContentIndexed = 8192
          Encrypted = 16384
          IntegrityStream = 32768
          NoScrubData = 131072
          Exists
          Indicates whether the folder exists.
          Extension
          The extension of the folder name, including the dot.
          FullName
          Fully qualified path of the folder where the file is located.
          Name
          Name of the folder where the file is located.
        DirectoryName
        Fully qualified path of the folder where the file is located.
        Exists
        Indicates whether the file exists.
        Extension
        The file extension including the dot separator (e.g. .exe, .dll).
        FullName
        The full name of the file including the file path. Example: C:\My Folder\File.txt
        Name
        File name without folder path.

Examples:

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

Beckhoff parameter:

    bFileAccessGetFileInfo
    A boolean variable that can be used to trigger the execution of the GetFileInfo command.
    OutputDataFileAccessGetFileInfo
    An instance of "ST_GetFileInfoOutputData" into which the return value of the GetFileInfo method is written.
    hrFileAccessGetFileInfo
    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
     bFileAccessGetFileInfo        : BOOL;
     OutputDataFileAccessGetFileInfo      : ST_GetFileInfoOutputData;
     hrFileAccessGetFileInfo        : HRESULT;

     fbFileAccess  : FB_FileAccess;
END_VAR

hrFileAccessGetFileInfo := fbFileAccess.GetFileInfo(
           bExecute     := bFileAccessGetFileInfo,   
           ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
           sfullPathSourceFile  := 'C:\Test\text.txt',
           OutputData    => OutputDataFileAccessGetFileInfo);
IF hrFileAccessGetFileInfo <> S_FALSE THEN 
     bFileAccessGetFileInfo := 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".