# SafeOpcFileHandle Members

> Reference: Represents a wrapper class for a OPC UA file handle.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">SafeOpcFileHandle</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>

Inherits members from [SafeHandleZeroOrMinusOneIsInvalid](https://learn.microsoft.com/dotnet/api/microsoft.win32.safehandles.safehandlezeroorminusoneisinvalid), [SafeHandle](https://learn.microsoft.com/dotnet/api/system.runtime.interopservices.safehandle).

## Constructors

### SafeOpcFileHandle

Initializes a new instance of the [SafeOpcFileHandle](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.safeopcfilehandle/) class using the specified `context` used to acquire the handle `value` passed.

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

```csharp
public SafeOpcFileHandle(OpcFileNodeContext context, uint value)
```

</div>

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

```vbnet
<CLSCompliant(False)>
Public Sub New(context As OpcFileNodeContext, value As UInteger)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcFileNodeContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilenodecontext/) | The [OpcFileNodeContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilenodecontext/) used to acquire the handle to wrap and which is to be used by the safe handle to release the handle. |
| `value` | [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) | The pre-existing handle to use. |

**Exceptions**

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

## Properties

### Context

Gets the [OpcFileNodeContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilenodecontext/) within that the stored handle has been acquired and will be released in case there the wrapper gets disposed of or closed.

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

```csharp
public OpcFileNodeContext Context { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Context As OpcFileNodeContext
```

</div>

**Property value**

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

An instance of the [OpcFileNodeContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcfilenodecontext/) class.

## Methods

### ReleaseHandle

<span class="api-meta">protected · override</span>

Executes the code required to free the handle.

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

```csharp
protected override bool ReleaseHandle()
```

</div>

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

```vbnet
Protected Overrides Function ReleaseHandle() As Boolean
```

</div>

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the handle is released successfully; otherwise in the event of a catastrophic failure the value false. In this case, it generates a releaseHandleFailed MDA Managed Debugging Assistant.

**Overrides**

[ReleaseHandle()](https://learn.microsoft.com/dotnet/api/system.runtime.interopservices.safehandle.releasehandle)
