# OpcFileWriteMethodNode.FileWriteExCallback Delegate

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

Write is used to write a part of the file starting from the current file position. The file position is advanced by the number of bytes written.

## Syntax

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

```csharp
public delegate void OpcFileWriteMethodNode.FileWriteExCallback(
    OpcMethodContext context,
    uint fileHandle,
    ByteString data)
```

</div>

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

```vbnet
<CLSCompliant(False)>
Public Delegate Sub OpcFileWriteMethodNode.FileWriteExCallback(
    context As OpcMethodContext,
    fileHandle As UInteger,
    data As ByteString)
```

</div>

## Parameters

| Name | Type | Description |
|---|---|---|
| `context` | [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) | The [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) to use when writing data to the file. This instance will be also updated with the outcome of the method call. |
| `fileHandle` | [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) | A file handle indicating the access request and thus indirectly the position inside the file. |
| `data` | [ByteString](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.bytestring/) | Contains the data to be written at the position of the file. It is server-dependent whether the written data are persistently stored if the session is ended without calling the Close Method with the file handle. |

## Remarks

This method does provide the following [OpcResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcresult/) information:

- [BadInvalidArgument](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badinvalidargument)The file handle specified by `fileHandle` or the [SessionId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/members#sessionid) is not known.
- [BadNotWritable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnotwritable)The file might be locked and thus not writable. This is also the case there neither 'CanWrite' nor 'CanUserWrite' grant write access.
- [BadUnexpectedError](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badunexpectederror)An unexpected error occurred while writing the file.
- [BadInvalidState](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badinvalidstate)The file was not opened for write access.

## Applies to

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