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

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

# File.ReadBytes

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

## ReadBytes(int offset, int count)

Reads a sequence of bytes from the file.

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
byte[] ReadBytes(int offset, int count)
```

Python:

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

### Parameters

- `offset` (`int`, Python `int`): File byte offset
- `count` (`int`, Python `int`): Count of bytes to read

### Returns

`byte[]` — byte[]

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    var header = DataFile.ReadBytes(0, 16);
    Print("File header: {0}", Encoding.UTF8.GetString(header));
}
```

Python:

```python
from System.Text import Encoding

header = api.DataFile.ReadBytes(0, 16)
api.Print(f"File header: {Encoding.UTF8.GetString(header)}")
```

config.json:

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

