Skip to content

Reference

OpcFile Members

Provides static (Shared in Visual Basic) methods for opening of a single file and aids in the creation of OpcFileStream objects.

Reference

OpcFile Members ​

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

Methods ​

AppendAllLines ​

static · 3 overloads

OverloadDescription
AppendAllLines(OpcClient, OpcNodeId, params string[])staticAppends lines to a file maintained by the file node specified by fileNodeId and then closes the file.
AppendAllLines(OpcClient, OpcNodeId, IEnumerable<string>)staticAppends lines to a file maintained by the file node specified by fileNodeId and then closes the file.
AppendAllLines(OpcClient, OpcNodeId, IEnumerable<string>, Encoding)staticAppends lines to a file maintained by the file node specified by fileNodeId by using a specified encoding and then closes the file.

Exceptions (all overloads)

ExceptionCondition
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

AppendAllLines(OpcClient, OpcNodeId, params string[]) ​

static

Appends lines to a file maintained by the file node specified by fileNodeId and then closes the file.

csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    params string[] contents)
vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    ParamArray contents As String())

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
contentsparams String[]The lines to append to the file maintained by the file node.

Exceptions

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

Remarks

Given the client, file node id and contents, this method opens the specified file, appends the contents to the end of the file, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

AppendAllLines(OpcClient, OpcNodeId, IEnumerable<string>) ​

static

Appends lines to a file maintained by the file node specified by fileNodeId and then closes the file.

csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    IEnumerable<string> contents)
vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As IEnumerable(Of String))

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
contentsIEnumerable<String>The lines to append to the file maintained by the file node.

Exceptions

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

Remarks

Given the client, file node id and contents, this method opens the specified file, appends the contents to the end of the file, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

AppendAllLines(OpcClient, OpcNodeId, IEnumerable<string>, Encoding) ​

static

Appends lines to a file maintained by the file node specified by fileNodeId by using a specified encoding and then closes the file.

csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    IEnumerable<string> contents,
    Encoding encoding)
vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As IEnumerable(Of String),
    encoding As Encoding)

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
contentsIEnumerable<String>The lines to append to the file maintained by the file node.
encodingEncodingThe character encoding to use.

Exceptions

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

Remarks

Given the client, file node id and contents, this method opens the specified file, appends the contents to the end of the file, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

AppendAllText ​

static · 2 overloads

OverloadDescription
AppendAllText(OpcClient, OpcNodeId, string)staticAppends the specified string to the file maintained by the file node specified by fileNodeId and then closes the file.
AppendAllText(OpcClient, OpcNodeId, string, Encoding)staticAppends the specified string to the file maintained by the file node specified by fileNodeId by using a specified encoding and then closes the file.

Exceptions (all overloads)

ExceptionCondition
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

AppendAllText(OpcClient, OpcNodeId, string) ​

static

Appends the specified string to the file maintained by the file node specified by fileNodeId and then closes the file.

csharp
public static void AppendAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    string contents)
vbnet
Public Shared Sub AppendAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As String)

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
contentsStringThe string to append to the file maintained by the file node.

Exceptions

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

Remarks

Given the client, file node id and string, this method opens the specified file, appends the string to the end of the file, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

AppendAllText(OpcClient, OpcNodeId, string, Encoding) ​

static

Appends the specified string to the file maintained by the file node specified by fileNodeId by using a specified encoding and then closes the file.

csharp
public static void AppendAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    string contents,
    Encoding encoding)
vbnet
Public Shared Sub AppendAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As String,
    encoding As Encoding)

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
contentsStringThe string to append to the file maintained by the file node.
encodingEncodingThe character encoding to use.

Exceptions

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

Remarks

Given the client, file node id, string and encoding, this method opens the specified file, appends the string to the end of the file, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised.

AppendText ​

static · 2 overloads

OverloadDescription
AppendText(OpcClient, OpcNodeId)staticCreates a StreamWriter that appends UTF8 encoded text to the file maintained by the file node specified by fileNodeId.
AppendText(OpcClient, OpcNodeId, Encoding)staticCreates a StreamWriter that appends text by using a specified encoding to the file maintained by the file node specified by fileNodeId.

Exceptions (all overloads)

ExceptionCondition
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

AppendText(OpcClient, OpcNodeId) ​

static

Creates a StreamWriter that appends UTF8 encoded text to the file maintained by the file node specified by fileNodeId.

csharp
public static StreamWriter AppendText(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function AppendText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As StreamWriter

Parameters

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

Returns

StreamWriter

A stream writer that appends UTF8 encoded text to the specified file node.

Exceptions

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

AppendText(OpcClient, OpcNodeId, Encoding) ​

static

Creates a StreamWriter that appends text by using a specified encoding to the file maintained by the file node specified by fileNodeId.

csharp
public static StreamWriter AppendText(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
vbnet
Public Shared Function AppendText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    encoding As Encoding) As StreamWriter

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
encodingEncodingThe character encoding to use.

Returns

StreamWriter

A stream writer that appends text to the specified file node.

Exceptions

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

Open ​

static

Opens a file in the specified mode.

csharp
public static OpcFileStream Open(
    OpcClient client,
    OpcNodeId fileNodeId,
    OpcFileMode mode)
vbnet
Public Shared Function Open(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    mode As OpcFileMode) As OpcFileStream

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
modeOpcFileModeA OpcFileMode member specifying the mode in which to open the file.

Returns

OpcFileStream

A OpcFileStream opened in the specified mode.

Exceptions

ExceptionCondition
ArgumentNullExceptionThe client or fileNodeId is a null reference (Nothing in Visual Basic).
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

OpenRead ​

static

Creates a read-only OpcFileStream.

csharp
public static OpcFileStream OpenRead(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function OpenRead(
    client As OpcClient,
    fileNodeId As OpcNodeId) As OpcFileStream

Parameters

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

Returns

OpcFileStream

A new read-only OpcFileStream object.

Exceptions

ExceptionCondition
ArgumentNullExceptionThe client or fileNodeId is a null reference (Nothing in Visual Basic).
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

Remarks

This method returns a read-only OpcFileStream object with the mode set to Read.

OpenText ​

static

Creates a StreamReader with UTF8 encoding.

csharp
public static StreamReader OpenText(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function OpenText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As StreamReader

Parameters

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

Returns

StreamReader

A new StreamReader with UTF8 encoding.

Exceptions

ExceptionCondition
ArgumentNullExceptionThe client or fileNodeId is a null reference (Nothing in Visual Basic).
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

OpenWrite ​

static

Creates a write-only OpcFileStream.

csharp
public static OpcFileStream OpenWrite(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function OpenWrite(
    client As OpcClient,
    fileNodeId As OpcNodeId) As OpcFileStream

Parameters

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

Returns

OpcFileStream

A write-only OpcFileStream object.

Exceptions

ExceptionCondition
ArgumentNullExceptionThe client or fileNodeId is a null reference (Nothing in Visual Basic).
InvalidOperationExceptionThe file node referenced by the fileNodeId specified 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").

ReadAllBytes ​

static

Opens a binary file node, reads the contents of the file node into a byte array, and then closes the file node.

csharp
public static byte[] ReadAllBytes(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function ReadAllBytes(
    client As OpcClient,
    fileNodeId As OpcNodeId) As Byte()

Parameters

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

Returns

Byte[]

A byte array containing the contents of the file maintained by the file node.

Exceptions

ExceptionCondition
ArgumentNullExceptionThe client or fileNodeId is a null reference (Nothing in Visual Basic).
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.

ReadAllLines ​

static · 2 overloads

OverloadDescription
ReadAllLines(OpcClient, OpcNodeId)staticOpens a text file node, reads all lines of the file maintained by the file node, and then closes the file node.
ReadAllLines(OpcClient, OpcNodeId, Encoding)staticOpens a file node, reads all lines of the file maintained by the file node with the specified encoding, and then closes the file node.

Exceptions (all overloads)

ExceptionCondition
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.
OutOfMemoryExceptionThere is insufficient memory to allocate a buffer for the returned string.

ReadAllLines(OpcClient, OpcNodeId) ​

static

Opens a text file node, reads all lines of the file maintained by the file node, and then closes the file node.

csharp
public static string[] ReadAllLines(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function ReadAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId) As String()

Parameters

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

Returns

String[]

A string array containing all lines of the file maintained by the file node.

Exceptions

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

ReadAllLines(OpcClient, OpcNodeId, Encoding) ​

static

Opens a file node, reads all lines of the file maintained by the file node with the specified encoding, and then closes the file node.

csharp
public static string[] ReadAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
vbnet
Public Shared Function ReadAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    encoding As Encoding) As String()

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
encodingEncodingThe encoding applied to the contents of the file node.

Returns

String[]

A string array containing all lines of the file maintained by the file node.

Exceptions

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

ReadAllText ​

static · 2 overloads

OverloadDescription
ReadAllText(OpcClient, OpcNodeId)staticOpens a file node, reads all lines of the file maintained by the file node, and then closes the file node.
ReadAllText(OpcClient, OpcNodeId, Encoding)staticOpens a file node, reads all lines of the file maintained by the file node with the specified encoding, and then closes the file node.

Exceptions (all overloads)

ExceptionCondition
InvalidOperationExceptionThe file node referenced by the fileNodeId specified could not be found.
OutOfMemoryExceptionThere is insufficient memory to allocate a buffer for the returned string.

ReadAllText(OpcClient, OpcNodeId) ​

static

Opens a file node, reads all lines of the file maintained by the file node, and then closes the file node.

csharp
public static string ReadAllText(OpcClient client, OpcNodeId fileNodeId)
vbnet
Public Shared Function ReadAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As String

Parameters

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

Returns

String

A string containing all lines of the file maintained by the file node.

Exceptions

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

ReadAllText(OpcClient, OpcNodeId, Encoding) ​

static

Opens a file node, reads all lines of the file maintained by the file node with the specified encoding, and then closes the file node.

csharp
public static string ReadAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
vbnet
Public Shared Function ReadAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    encoding As Encoding) As String

Parameters

NameTypeDescription
clientOpcClientThe OpcClient to use when accessing the file node.
fileNodeIdOpcNodeIdThe OpcNodeId of the file node to access.
encodingEncodingThe encoding applied to the contents of the file.

Returns

String

A string containing all lines of the file maintained by the file node.

Exceptions

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