Skip to content

Reference

OpcFileInfo Members

Provides properties and instance methods for the opening of files and aids in the creation of OpcFileStream objects.

Reference

OpcFileInfo Members ​

Type
OpcFileInfo
Namespace
Opc.UaFx.Client
Assembly
Opc.UaFx.Advanced.dll
Package
Opc.UaFx.Advanced v2.59.0
Also in
Opc.UaFx.Client

Constructors ​

OpcFileInfo ​

2 overloads

OverloadDescription
OpcFileInfo(OpcFileNodeContext)Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the context specified.
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.

OpcFileInfo(OpcFileNodeContext) ​

Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the context specified.

csharp
public OpcFileInfo(OpcFileNodeContext context)
vbnet
Public Sub New(context As OpcFileNodeContext)

Parameters

NameTypeDescription
contextOpcFileNodeContextThe OpcFileNodeContext identifying the file node to be wrapped by the new instance.

Exceptions

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

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.

csharp
public OpcFileInfo(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Sub New(client As OpcClient, fileNodeId As OpcNodeId)

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node information.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to wrap.

Exceptions

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

Properties ​

CanUserWrite ​

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

csharp
public bool CanUserWrite { get; }
vbnet
Public ReadOnly Property CanUserWrite As Boolean

Property value

Boolean

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

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public bool CanWrite { get; }
vbnet
Public ReadOnly Property CanWrite As Boolean

Property value

Boolean

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

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public OpcFileNodeContext Context { get; }
vbnet
Public ReadOnly Property Context As OpcFileNodeContext

Property value

OpcFileNodeContext

An instance of the OpcFileNodeContext class.

Exists ​

Gets a value indicating whether the file node represented exists.

csharp
public bool Exists { get; }
vbnet
Public ReadOnly Property Exists As Boolean

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.

csharp
public long Length { get; }
vbnet
Public ReadOnly Property Length As Long

Property value

Int64

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

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public string MimeType { get; }
vbnet
Public ReadOnly Property MimeType As String

Property value

String

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

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public OpcName Name { get; }
vbnet
Public ReadOnly Property Name As OpcName

Property value

OpcName

The OpcName of the file node described.

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

Methods ​

AppendText ​

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

csharp
public StreamWriter AppendText()
vbnet
Public Function AppendText() As StreamWriter

Returns

StreamWriter

A new instance of the StreamWriter class.

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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 ​

Opens a file in the specified mode.

csharp
public OpcFileStream Open(OpcFileMode mode)
vbnet
Public Function Open(mode As OpcFileMode) As OpcFileStream

Parameters

NameTypeDescription
modeOpcFileModeA OpcFileMode member specifying the mode in which to open the file.

Returns

OpcFileStream

A OpcFileStream opened in the specified mode.

Exceptions

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

OpenRead ​

Creates a read-only OpcFileStream.

csharp
public OpcFileStream OpenRead()
vbnet
Public Function OpenRead() As OpcFileStream

Returns

OpcFileStream

A new read-only OpcFileStream object.

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public StreamReader OpenText()
vbnet
Public Function OpenText() As StreamReader

Returns

StreamReader

A new StreamReader with UTF8 encoding.

Exceptions

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

OpenWrite ​

Creates a write-only OpcFileStream.

csharp
public OpcFileStream OpenWrite()
vbnet
Public Function OpenWrite() As OpcFileStream

Returns

OpcFileStream

A write-only OpcFileStream object.

Exceptions

ExceptionCondition
InvalidOperationExceptionThe 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.

csharp
public void Refresh()
vbnet
Public Sub 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 ​

override

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

csharp
public override string ToString()
vbnet
Public Overrides Function ToString() As String

Returns

String

A string representing the file node described.

Overrides

ToString()