OpcFileInfo Members

Namespace: Opc.UaFx.Client
Assemblies: Opc.UaFx.Advanced.dll, Opc.UaFx.Advanced.dll
The OpcFileInfo type exposes the following members.

OpcFileInfo(OpcClient, OpcNodeId)

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

ArgumentNullException

The client or fileNodeId is a null reference (Nothing in Visual Basic).

OpcFileInfo(OpcFileNodeContext)

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

ArgumentNullException

The context is a null reference (Nothing in Visual Basic).

CanUserWrite

Gets a value indicating whether the file is writable taking user access rights into account.

C#

public bool CanUserWrite { get; }


Property Value

Boolean

The value true if the current file can be written by the current user; otherwise the value false.



Exceptions

InvalidOperationException

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.

CanWrite

Gets a value indicating whether the file is writable.

C#

public bool CanWrite { get; }


Property Value

Boolean

The value true if the current file can be written; otherwise the value false.



Exceptions

InvalidOperationException

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.

Context

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

OpcFileNodeContext

An instance of the OpcFileNodeContext class.

Exists

Gets a value indicating whether the file node represented exists.

C#

public bool Exists { get; }


Property Value

Boolean

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.

Length

Gets the size, in bytes, of the current file represented by the file node described.

C#

public long Length { get; }


Property Value

Int64

The size of the file of the current file node in bytes.



Exceptions

InvalidOperationException

The file node described by the current OpcFileInfo object could not be found.



Remarks

To get the latest value, call the Refresh method.

MimeType

Gets the media type of the current file represented by the file node described.

C#

public string MimeType { get; }


Property Value

String

The media type of the file of the current file node based on RFC 2046.



Exceptions

InvalidOperationException

The file node described by the current OpcFileInfo object could not be found.



Remarks

To get the latest value, call the Refresh method.

Name

Gets the name of the file node described.

C#

public OpcName Name { get; }


Property Value

OpcName

The OpcName of the file node described.



Exceptions

InvalidOperationException

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.

AppendText()

Creates a StreamWriter that appends text to the file represented by this instance of the OpcFileInfo.

C#

public StreamWriter AppendText()


Returns

StreamWriter

A new instance of the StreamWriter class.



Exceptions

InvalidOperationException

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.

Open(OpcFileMode)

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

OpcFileStream

A OpcFileStream opened in the specified mode.



Exceptions

InvalidOperationException

The file node described by the current OpcFileInfo object could not be found.

OpenRead()

Creates a read-only OpcFileStream.

C#

public OpcFileStream OpenRead()


Returns

OpcFileStream

A new read-only OpcFileStream object.



Exceptions

InvalidOperationException

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.

OpenText()

Creates a StreamReader with UTF8 encoding.

C#

public StreamReader OpenText()


Returns

StreamReader

A new StreamReader with UTF8 encoding.



Exceptions

InvalidOperationException

The file node described by the current OpcFileInfo object could not be found.

OpenWrite()

Creates a write-only OpcFileStream.

C#

public OpcFileStream OpenWrite()


Returns

OpcFileStream

A write-only OpcFileStream object.



Exceptions

InvalidOperationException

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”).

Refresh()

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.

ToString()

Returns the OpcNodeId or the Value of the file node described.

C#

public override string ToString()


Returns

String

A string representing the file node described.