Namespace: Opc.UaFx.Client
Assemblies: Opc.UaFx.Advanced.dll, Opc.UaFx.Advanced.dll
The OpcFileInfo type exposes the following members.
Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the fileNodeId
and accessed using the client
specified.
C#
public OpcFileInfo(OpcClient client, OpcNodeId fileNodeId)
Parameters
client
OpcClient
The OpcClient to use when accessing the file node information.
fileNodeId
OpcNodeId
The OpcNodeId of the file node to wrap.
Exceptions
The client
or fileNodeId
is a null reference (Nothing in Visual Basic).
Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the context
specified.
C#
public OpcFileInfo(OpcFileNodeContext context)
Parameters
context
OpcFileNodeContext
The OpcFileNodeContext identifying the file node to be wrapped by the new instance.
Exceptions
The context
is a null reference (Nothing in Visual Basic).
Gets a value indicating whether the file is writable taking user access rights into account.
C#
public bool CanUserWrite { get; }
Property Value
The value true if the current file can be written by the current user; otherwise the value false.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
This property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
Gets a value indicating whether the file is writable.
C#
public bool CanWrite { get; }
Property Value
The value true if the current file can be written; otherwise the value false.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
This property does not take any user access rights into account, i.e. although the file is writable this may be restricted to a certain user / user group. The property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
Gets the OpcFileNodeContext used to wrap and access the file node its information is to be provided by the OpcFileInfo.
C#
public OpcFileNodeContext Context { get; }
Property Value
An instance of the OpcFileNodeContext class.
Gets a value indicating whether the file node represented exists.
C#
public bool Exists { get; }
Property Value
The value true if the file node exists; otherwise the value false if the file node does not exist.
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
The Exists property returns false if any error occurs while trying to determine if the specified file node exists. This can occur in situations that raise exceptions.
Gets the size, in bytes, of the current file represented by the file node described.
C#
public long Length { get; }
Property Value
The size of the file of the current file node in bytes.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
To get the latest value, call the Refresh method.
Gets the media type of the current file represented by the file node described.
C#
public string MimeType { get; }
Property Value
The media type of the file of the current file node based on RFC 2046.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
To get the latest value, call the Refresh method.
Gets the name of the file node described.
C#
public OpcName Name { get; }
Property Value
The OpcName of the file node described.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
Creates a StreamWriter that appends text to the file represented by this instance of the OpcFileInfo.
C#
public StreamWriter AppendText()
Returns
A new instance of the StreamWriter class.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
This method returns a write-only OpcFileStream object with the mode set to AppendWrite.
Opens a file in the specified mode
.
C#
public OpcFileStream Open(OpcFileMode mode)
Parameters
mode
OpcFileMode
A OpcFileMode member specifying the mode in which to open the file.
Returns
A OpcFileStream opened in the specified mode.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Creates a read-only OpcFileStream.
C#
public OpcFileStream OpenRead()
Returns
A new read-only OpcFileStream object.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
This method returns a read-only OpcFileStream object with the mode set to Read.
Creates a StreamReader with UTF8 encoding.
C#
public StreamReader OpenText()
Returns
A new StreamReader with UTF8 encoding.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Creates a write-only OpcFileStream.
C#
public OpcFileStream OpenWrite()
Returns
A write-only OpcFileStream object.
Exceptions
The file node described by the current OpcFileInfo object could not be found.
Remarks
This method returns a write-only OpcFileStream object with the mode set to Write.
The stream created does not append the new content to the existing content. Instead, it overwrites the existing data with the new data. If you overwrite longer data (such as “This is a test of the OpenWrite method”) with a shorter string (like “Second ”), the file will contain a mix of the strings (“Second test of the OpenWrite method”).
Refreshes the state and information of the OpcFileInfo object.
C#
public void Refresh()
Remarks
The method takes a snapshot of the file node.
Calls must be made to Refresh before attempting to get any information, or the information will be outdated.