---
id: "T:cAlgo.API.OpenFileDialog"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/"
---

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

# OpenFileDialog (class)

Represents a common dialog box that allows a user to specify a filename for one or more files to open.

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

- CLI: No dialog can be shown in the CLI: ShowDialog returns FileDialogResult.None and the dialog settings are only stored.
- Cloud: No dialog can be shown in the cloud: ShowDialog returns FileDialogResult.None and the dialog settings are only stored.

## Definition

```csharp
public class OpenFileDialog
```

Available since cAlgo.API 5.1.

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo.Robots;

public partial class TestExample : Robot
{
    protected override void OnStart()
    {
        var openFileDialog = new OpenFileDialog
        {
            Title = "Select File(s)",
            Multiselect = true,
            AddExtension = true,
        };

        var result = openFileDialog.ShowDialog();

        if (result == FileDialogResult.Cancel)
            return;

        foreach (var fileName in openFileDialog.FileNames)
        {
            Print(fileName);
        }
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        openFileDialog = OpenFileDialog()
        openFileDialog.Title = "Select File(s)"
        openFileDialog.Multiselect = True
        openFileDialog.AddExtension = True

        result = openFileDialog.ShowDialog()

        if result == FileDialogResult.Cancel:
            return

        for fileName in openFileDialog.FileNames:
            api.Print(fileName)
```

config.json:

```json
{
  "AccessRights": "None"
}
```

## Constructors

- `public OpenFileDialog()` — Creates an OpenFileDialog. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/Constructor/index.md)

## Methods

- `public void Reset()` — Resets all dialog properties to their default values. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/Reset/index.md)
- `public FileDialogResult ShowDialog()` — Shows a file dialog, with the owner as the main Window [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/ShowDialog/index.md)
- `public FileDialogResult ShowDialog(Window owner)` — Shows a file dialog, with the passed owner window. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/ShowDialog/index.md)

## Properties

- `public bool AddExtension {get; set;}` — Gets or sets a value indicating whether a file dialog automatically adds an extension to a file name if the user omits an extension. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/AddExtension/index.md)
- `public string DefaultExt {get; set;}` — Gets or sets a value that specifies the default extension string to use to filter the list of files that are displayed. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/DefaultExt/index.md)
- `public string FileName {get;}` — Gets a string containing the full path of the file selected in a file dialog. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/FileName/index.md)
- `public string[] FileNames {get;}` — Gets an array that contains one file name for each selected file. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/FileNames/index.md)
- `public string Filter {get; set;}` — Gets or sets the filter string that determines what types of files are displayed in file dialog. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/Filter/index.md)
- `public string InitialDirectory {get; set;}` — Gets or sets the initial directory that is displayed by a file dialog. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/InitialDirectory/index.md)
- `public bool Multiselect {get; set;}` — Gets or sets an option indicating whether OpenFileDialog allows users to select multiple files. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/Multiselect/index.md)
- `public string Title {get; set;}` — Gets or sets a string shown in the title bar of the dialog. If this property is null, a localized default from the operating system itself will be used. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/Title/index.md)
- `public bool ValidateNames {get; set;}` — Gets or sets a value indicating whether the dialog accepts only valid file names. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/OpenFileDialog/ValidateNames/index.md)

