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

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

# File.WriteAllText

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

## WriteAllText(string contents)

Overwrites file content with passed text content.

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 WriteAllText(string contents)
```

Python:

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

### Parameters

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

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    DataFile.WriteAllText($"{SymbolName},{Symbol.Bid},{Symbol.Ask}");
}
```

Python:

```python
api.DataFile.WriteAllText(f"{api.SymbolName},{api.Symbol.Bid},{api.Symbol.Ask}")
```

config.json:

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

## WriteAllText(string contents, EncodingType encodingType)

Overwrites file content with passed text content 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 WriteAllText(string contents, EncodingType encodingType)
```

Python:

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

### Parameters

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

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    DataFile.WriteAllText($"{SymbolName},{Symbol.Bid}", EncodingType.Utf8);
}
```

Python:

```python
api.DataFile.WriteAllText(f"{api.SymbolName},{api.Symbol.Bid}", EncodingType.Utf8)
```

config.json:

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

