# OpcFileStream Class

> Reference: Provides a Stream for a file node.

<dl class="api-definition">
<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>Members</dt>
<dd><a href="./members">OpcFileStream Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Provides a [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream) for a file node.

## Syntax

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

```csharp
public class OpcFileStream : Stream
```

</div>

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

```vbnet
Public Class OpcFileStream
    Inherits Stream
```

</div>

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) → [MarshalByRefObject](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject) → [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream) → **OpcFileStream**

## Implements

<ul class="api-implements">
<li><a href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></li>
</ul>

## Constructors

| Name | Description |
|---|---|
| [OpcFileStream](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#opcfilestream)<span class="api-meta">3 overloads</span> | Initializes a new instance of the OpcFileStream class using the specified `file` and `mode`. |

## Properties

| Name | Description |
|---|---|
| [CanRead](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#canread)<span class="api-meta">override</span> | Gets a value indicating whether the current stream supports reading. |
| [CanSeek](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#canseek)<span class="api-meta">override</span> | Gets a value indicating whether the current stream supports seeking. |
| [CanWrite](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#canwrite)<span class="api-meta">override</span> | Gets a value indicating whether the current stream supports writing. |
| [File](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#file) | Gets the [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfileinfo/) used to determine the file accessibility and its size. |
| [Handle](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#handle) | Gets a [SafeOpcFileHandle](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.safeopcfilehandle/) object that represents the file handle for the file that the current OpcFileStream object encapsulates. |
| [Length](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#length)<span class="api-meta">override</span> | Gets the length in bytes of the stream. |
| [Position](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#position)<span class="api-meta">override</span> | Gets or sets the position within the current stream. |

## Methods

| Name | Description |
|---|---|
| [Close](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#close)<span class="api-meta">override</span> | Closes the current stream and releases any resources associated with the current stream. |
| [Flush](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#flush)<span class="api-meta">override</span> | Clears all buffers for this stream and causes any buffered data to be written to the underlying device. |
| [Read](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#read)<span class="api-meta">override</span> | Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. |
| [Seek](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#seek)<span class="api-meta">override</span> | Sets the position within the current stream. |
| [SetLength](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#setlength)<span class="api-meta">override</span> | Sets the length of the current stream. |
| [Write](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilestream/members#write)<span class="api-meta">override</span> | Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. |

Inherits members from [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream), [MarshalByRefObject](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject).

## Applies to

| Package | Versions |
|---|---|
| Opc.UaFx.Advanced | v2.5–v2.59 |
