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

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

# File.Exists

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

## Exists()

Returns True if File exists otherwise False.

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
bool Exists()
```

Python:

```python
file.Exists() -> bool
```

### Returns

`bool` — bool

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
protected override void OnStart()
{
    if (!DataFile.Exists())
        DataFile.WriteAllText("Symbol,Price");
}
```

Python:

```python
if not api.DataFile.Exists():
    api.DataFile.WriteAllText("Symbol,Price")
```

config.json:

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

