---
id: "M:cAlgo.API.FileAssociations.Add(System.String,System.String)"
kind: "method"
type: "T:cAlgo.API.FileAssociations"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/FileAssociation/FileAssociations/Add/"
---

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

# FileAssociations.Add

Member of [FileAssociations](https://help.ctrader.com/ctrader-algo/references/Plugin/FileAssociation/FileAssociations/index.md).

## Add(string fileExtension, string iconFilePath)

Adds a file extension to the list of associations along with a specified icon file path.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
void Add(string fileExtension, string iconFilePath)
```

Python:

```python
api.FileAssociations.Add(fileExtension: str, iconFilePath: str) -> None
```

### Parameters

- `fileExtension` (`string`, Python `str`): File extension with dot, ex: .pdf
- `iconFilePath` (`string`, Python `str`): Icon file path

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
FileAssociations.Add(".mydata", @"C:\Users\Me\Documents\icons\mydata.ico");
Print("Associated: {0}", FileAssociations.Contains(".mydata"));
```

Python:

```python
api.FileAssociations.Add(".mydata", r"C:\Users\Me\Documents\icons\mydata.ico")
api.Print(f"Associated: {api.FileAssociations.Contains('.mydata')}")
```

## Add(string fileExtension, SvgIcon svgIcon)

Adds a file extension to the list of associations along with a specified icon file path.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
void Add(string fileExtension, SvgIcon svgIcon)
```

Python:

```python
api.FileAssociations.Add(fileExtension: str, svgIcon: SvgIcon) -> None
```

### Parameters

- `fileExtension` (`string`, Python `str`): File extension with dot, ex: .pdf
- `svgIcon` (`SvgIcon`, Python `SvgIcon`): SVG Icon

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
var icon = new SvgIcon("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='8' cy='8' r='6' fill='#2F4BFF' /></svg>");
FileAssociations.Add(".mydata", icon);
Print("Associated: {0}", FileAssociations.Contains(".mydata"));
```

Python:

```python
icon = SvgIcon("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='8' cy='8' r='6' fill='#2F4BFF' /></svg>")
api.FileAssociations.Add(".mydata", icon)
api.Print(f"Associated: {api.FileAssociations.Contains('.mydata')}")
```

## Add(string fileExtension)

Adds a file extension to the list of associations without specifying an icon.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
void Add(string fileExtension)
```

Python:

```python
api.FileAssociations.Add(fileExtension: str) -> None
```

### Parameters

- `fileExtension` (`string`, Python `str`): File extension with dot, ex: .pdf

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
FileAssociations.Add(".mydata");
foreach (var fileExtension in FileAssociations)
    Print("Associated extension: {0}", fileExtension);
```

Python:

```python
api.FileAssociations.Add(".mydata")
for fileExtension in api.FileAssociations:
    api.Print(f"Associated extension: {fileExtension}")
```

