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

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

# SaveFileDialog (class)

Represents a common dialog box that allows a user to specify a filename to save.

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

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

## Definition

```csharp
public class SaveFileDialog
```

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 saveFileDialog = new SaveFileDialog
        {
            Title = "Save File",
            AddExtension = true,
        };

        var result = saveFileDialog.ShowDialog();

        if (result == FileDialogResult.Cancel)
            return;

        saveFileDialog.WriteToFile("Write to selected user file here");
    }
}
```

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):
        saveFileDialog = SaveFileDialog()
        saveFileDialog.Title = "Save File"
        saveFileDialog.AddExtension = True

        result = saveFileDialog.ShowDialog()

        if result == FileDialogResult.Cancel:
            return

        saveFileDialog.WriteToFile("Write to selected user file here")
```

config.json:

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

## Constructors

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

## Methods

- `public void Reset()` — Resets all dialog properties to their default values. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/SaveFileDialog/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/SaveFileDialog/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/SaveFileDialog/ShowDialog/index.md)
- `public void WriteToFile(string data)` — Writes data to selected file. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/SaveFileDialog/WriteToFile/index.md)
- `public void WriteToFile(byte[] data)` — Writes data to selected file. [details](https://help.ctrader.com/ctrader-algo/references/Dialogs/SaveFileDialog/WriteToFile/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/SaveFileDialog/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/SaveFileDialog/DefaultExt/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/SaveFileDialog/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/SaveFileDialog/InitialDirectory/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/SaveFileDialog/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/SaveFileDialog/ValidateNames/index.md)

