---
id: "M:cAlgo.API.File.ReadAllBytes"
kind: "method"
type: "T:cAlgo.API.File"
url: "https://help.ctrader.com/ctrader-algo/references/Utility/File/ReadAllBytes/"
---

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

# File.ReadAllBytes

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

## ReadAllBytes()

Reads the contents of the file into a byte array.

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[] ReadAllBytes()
```

Python:

```python
file.ReadAllBytes() -> list[int]
```

### Returns

`byte[]` — byte[]

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    var bytes = DataFile.ReadAllBytes();
    Print("Read {0} bytes from {1}", bytes.Length, DataFile.Name);
}
```

Python:

```python
data = api.DataFile.ReadAllBytes()
api.Print(f"Read {data.Length} bytes from {api.DataFile.Name}")
```

config.json:

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

