# OpcFile Members

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

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcFile</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.client">Opc.UaFx.Client</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

## Methods

### AppendAllLines

<span class="api-meta">static · 3 overloads</span>

| Overload | Description |
|---|---|
| [AppendAllLines(OpcClient, OpcNodeId, params string\[\])](#appendalllines-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-string-array)<span class="api-meta">static</span> | Appends lines to a file maintained by the file node specified by `fileNodeId` and then closes the file. |
| [AppendAllLines(OpcClient, OpcNodeId, IEnumerable&lt;string&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendalllines-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-collections-generic-ienumerable-of-system-string)<span class="api-meta">static</span> | Appends lines to a file maintained by the file node specified by `fileNodeId` and then closes the file. |
| [AppendAllLines(OpcClient, OpcNodeId, IEnumerable&lt;string&gt;, Encoding)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendalllines-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-collections-generic-ienumerable-of-system-string-system-text-encoding)<span class="api-meta">static</span> | Appends 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)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

#### AppendAllLines(OpcClient, OpcNodeId, params string\[\])

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    params string[] contents)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    ParamArray contents As String())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `contents` | params [String](https://learn.microsoft.com/dotnet/api/system.string)[] | The lines to append to the file maintained by the file node. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `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&lt;string&gt;)

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    IEnumerable<string> contents)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As IEnumerable(Of String))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `contents` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[String](https://learn.microsoft.com/dotnet/api/system.string)&gt; | The lines to append to the file maintained by the file node. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `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&lt;string&gt;, Encoding)

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static void AppendAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    IEnumerable<string> contents,
    Encoding encoding)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub AppendAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As IEnumerable(Of String),
    encoding As Encoding)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `contents` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[String](https://learn.microsoft.com/dotnet/api/system.string)&gt; | The lines to append to the file maintained by the file node. |
| `encoding` | [Encoding](https://learn.microsoft.com/dotnet/api/system.text.encoding) | The character encoding to use. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `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

<span class="api-meta">static · 2 overloads</span>

| Overload | Description |
|---|---|
| [AppendAllText(OpcClient, OpcNodeId, string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendalltext-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-string)<span class="api-meta">static</span> | Appends the specified string to the file maintained by the file node specified by `fileNodeId` and then closes the file. |
| [AppendAllText(OpcClient, OpcNodeId, string, Encoding)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendalltext-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-string-system-text-encoding)<span class="api-meta">static</span> | 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. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

#### AppendAllText(OpcClient, OpcNodeId, string)

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static void AppendAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    string contents)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub AppendAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `contents` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The string to append to the file maintained by the file node. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `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)

<span class="api-meta">static</span>

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.

<div class="api-signature" data-lang="csharp">

```csharp
public static void AppendAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    string contents,
    Encoding encoding)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub AppendAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    contents As String,
    encoding As Encoding)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `contents` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The string to append to the file maintained by the file node. |
| `encoding` | [Encoding](https://learn.microsoft.com/dotnet/api/system.text.encoding) | The character encoding to use. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `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

<span class="api-meta">static · 2 overloads</span>

| Overload | Description |
|---|---|
| [AppendText(OpcClient, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendtext-opc-uafx-client-opcclient-opc-uafx-opcnodeid)<span class="api-meta">static</span> | Creates a [StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter) that appends UTF8 encoded text to the file maintained by the file node specified by `fileNodeId`. |
| [AppendText(OpcClient, OpcNodeId, Encoding)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#appendtext-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-text-encoding)<span class="api-meta">static</span> | Creates a [StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter) that appends text by using a specified `encoding` to the file maintained by the file node specified by `fileNodeId`. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

#### AppendText(OpcClient, OpcNodeId)

<span class="api-meta">static</span>

Creates a [StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter) that appends UTF8 encoded text to the file maintained by the file node specified by `fileNodeId`.

<div class="api-signature" data-lang="csharp">

```csharp
public static StreamWriter AppendText(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function AppendText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As StreamWriter
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter)

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |

#### AppendText(OpcClient, OpcNodeId, Encoding)

<span class="api-meta">static</span>

Creates a [StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter) that appends text by using a specified `encoding` to the file maintained by the file node specified by `fileNodeId`.

<div class="api-signature" data-lang="csharp">

```csharp
public static StreamWriter AppendText(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
```

</div>

<div class="api-signature" data-lang="vbnet">

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

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `encoding` | [Encoding](https://learn.microsoft.com/dotnet/api/system.text.encoding) | The character encoding to use. |

**Returns**

[StreamWriter](https://learn.microsoft.com/dotnet/api/system.io.streamwriter)

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client`, `fileNodeId` or `encoding` is a null reference (Nothing in Visual Basic). |

### Open

<span class="api-meta">static</span>

Opens a file in the specified `mode`.

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcFileStream Open(
    OpcClient client,
    OpcNodeId fileNodeId,
    OpcFileMode mode)
```

</div>

<div class="api-signature" data-lang="vbnet">

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

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `mode` | [OpcFileMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/) | A [OpcFileMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/) member specifying the mode in which to open the file. |

**Returns**

[OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/)

A [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/) opened in the specified mode.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

### OpenRead

<span class="api-meta">static</span>

Creates a read-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/).

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcFileStream OpenRead(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function OpenRead(
    client As OpcClient,
    fileNodeId As OpcNodeId) As OpcFileStream
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/)

A new read-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/) object.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

**Remarks**

This method returns a read-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/) object with the mode set to [Read](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/#read).

### OpenText

<span class="api-meta">static</span>

Creates a [StreamReader](https://learn.microsoft.com/dotnet/api/system.io.streamreader) with UTF8 encoding.

<div class="api-signature" data-lang="csharp">

```csharp
public static StreamReader OpenText(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function OpenText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As StreamReader
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[StreamReader](https://learn.microsoft.com/dotnet/api/system.io.streamreader)

A new [StreamReader](https://learn.microsoft.com/dotnet/api/system.io.streamreader) with UTF8 encoding.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

### OpenWrite

<span class="api-meta">static</span>

Creates a write-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/).

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcFileStream OpenWrite(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function OpenWrite(
    client As OpcClient,
    fileNodeId As OpcNodeId) As OpcFileStream
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/)

A write-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/) object.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

**Remarks**

This method returns a write-only [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/) object with the mode set to [Write](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/#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

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static byte[] ReadAllBytes(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function ReadAllBytes(
    client As OpcClient,
    fileNodeId As OpcNodeId) As Byte()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[Byte](https://learn.microsoft.com/dotnet/api/system.byte)[]

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |

### ReadAllLines

<span class="api-meta">static · 2 overloads</span>

| Overload | Description |
|---|---|
| [ReadAllLines(OpcClient, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#readalllines-opc-uafx-client-opcclient-opc-uafx-opcnodeid)<span class="api-meta">static</span> | Opens 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)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#readalllines-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-text-encoding)<span class="api-meta">static</span> | 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. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |
| [OutOfMemoryException](https://learn.microsoft.com/dotnet/api/system.outofmemoryexception) | There is insufficient memory to allocate a buffer for the returned string. |

#### ReadAllLines(OpcClient, OpcNodeId)

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static string[] ReadAllLines(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function ReadAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId) As String()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)[]

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client` or `fileNodeId` is a null reference (Nothing in Visual Basic). |

#### ReadAllLines(OpcClient, OpcNodeId, Encoding)

<span class="api-meta">static</span>

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.

<div class="api-signature" data-lang="csharp">

```csharp
public static string[] ReadAllLines(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function ReadAllLines(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    encoding As Encoding) As String()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `encoding` | [Encoding](https://learn.microsoft.com/dotnet/api/system.text.encoding) | The encoding applied to the contents of the file node. |

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)[]

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client`, `fileNodeId` or `encoding` is a null reference (Nothing in Visual Basic). |

### ReadAllText

<span class="api-meta">static · 2 overloads</span>

| Overload | Description |
|---|---|
| [ReadAllText(OpcClient, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#readalltext-opc-uafx-client-opcclient-opc-uafx-opcnodeid)<span class="api-meta">static</span> | Opens a file node, reads all lines of the file maintained by the file node, and then closes the file node. |
| [ReadAllText(OpcClient, OpcNodeId, Encoding)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfile/members#readalltext-opc-uafx-client-opcclient-opc-uafx-opcnodeid-system-text-encoding)<span class="api-meta">static</span> | 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. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The file node referenced by the `fileNodeId` specified could not be found. |
| [OutOfMemoryException](https://learn.microsoft.com/dotnet/api/system.outofmemoryexception) | There is insufficient memory to allocate a buffer for the returned string. |

#### ReadAllText(OpcClient, OpcNodeId)

<span class="api-meta">static</span>

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

<div class="api-signature" data-lang="csharp">

```csharp
public static string ReadAllText(OpcClient client, OpcNodeId fileNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function ReadAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId) As String
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client`, `fileNodeId` is a null reference (Nothing in Visual Basic). |

#### ReadAllText(OpcClient, OpcNodeId, Encoding)

<span class="api-meta">static</span>

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.

<div class="api-signature" data-lang="csharp">

```csharp
public static string ReadAllText(
    OpcClient client,
    OpcNodeId fileNodeId,
    Encoding encoding)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function ReadAllText(
    client As OpcClient,
    fileNodeId As OpcNodeId,
    encoding As Encoding) As String
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `client` | [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) | The [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) to use when accessing the file node. |
| `fileNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) of the file node to access. |
| `encoding` | [Encoding](https://learn.microsoft.com/dotnet/api/system.text.encoding) | The encoding applied to the contents of the file. |

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `client`, `fileNodeId` or `encoding` is a null reference (Nothing in Visual Basic). |
