---
id: "M:cAlgo.API.File.WriteBytes(System.Byte[],System.Int32,System.Int32)"
kind: "method"
type: "T:cAlgo.API.File"
url: "https://help.ctrader.com/ctrader-algo/references/Utility/File/WriteBytes/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# File.WriteBytes

Member of [File](https://help.ctrader.com/ctrader-algo/references/Utility/File/index.md).

## WriteBytes(byte[] bytes, int offset, int count)

Writes a chunk of data to file specific position.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: Exists returns false; reads return empty string/array; writes and appends silently do nothing. No exception.

C#:

```csharp
void WriteBytes(byte[] bytes, int offset, int count)
```

Python:

```python
file.WriteBytes(bytes: list[int], offset: int, count: int) -> None
```

### Parameters

- `bytes` (`byte[]`, Python `list[int]`): Bytes to write
- `offset` (`int`, Python `int`): File byte offset
- `count` (`int`, Python `int`): Count of bytes to write

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    var bytes = Encoding.UTF8.GetBytes(SymbolName);
    DataFile.WriteBytes(bytes, 0, bytes.Length);
}
```

Python:

```python
from System.Text import Encoding

data = Encoding.UTF8.GetBytes(api.SymbolName)
api.DataFile.WriteBytes(data, 0, data.Length)
```

config.json:

```json
{
  "Parameters": [
    {
      "Name": "DataFile",
      "DisplayName": "Data File",
      "Type": "File"
    }
  ]
}
```

