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

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

# File.AppendAllText

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

## AppendAllText(string contents)

Append text to 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
void AppendAllText(string contents)
```

Python:

```python
file.AppendAllText(contents: str) -> None
```

### Parameters

- `contents` (`string`, Python `str`): The string to append to the file.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnBar()
{
    DataFile.AppendAllText($"{Bars.LastBar.OpenTime:O},{Bars.LastBar.Close}{Environment.NewLine}");
}
```

Python:

```python
def on_bar(self):
    lastBar = api.Bars.LastBar
    api.DataFile.AppendAllText(f"{lastBar.OpenTime},{lastBar.Close}\n")
```

config.json:

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

## AppendAllText(string contents, EncodingType encodingType)

Appends text to file that has a specified encoding.

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 AppendAllText(string contents, EncodingType encodingType)
```

Python:

```python
file.AppendAllText(contents: str, encodingType: EncodingType) -> None
```

### Parameters

- `contents` (`string`, Python `str`): The string to append to the file.
- `encodingType` (`EncodingType`, Python `EncodingType`): Encoding type

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    DataFile.AppendAllText($"{Server.Time:O},{Symbol.Bid}{Environment.NewLine}", EncodingType.Utf8);
}
```

Python:

```python
api.DataFile.AppendAllText(f"{api.Server.Time},{api.Symbol.Bid}\n", EncodingType.Utf8)
```

config.json:

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

