# RadOpenFolderDialog

**RadOpenFolderDialog** is a modal dialog box that allows you to specify one or multiple folder names to open.

> caption RadOpenFolderDialog in single selection mode

![WPF RadFileDialogs RadOpenFolderDialog in single selection mode](https://www.telerik.com/products/wpf/documentation/assets/f3b12da356b6e5eb042699c47b6155ff/radopenfolderdialog-01.png)

## Showing the Dialog

To show the dialog call its **ShowDialog** method. If a valid folder is opened when you press OK, the **DialogResult** property will return True and the **FileName**, and **FileNames** properties will be set. You can use FileName and FileNames to get the names of the selected folders.

> Note that when the ShowDialog method is called the UI of the host application will freeze until the dialog closes.

**Example 1: Show a open folder dialog**

```C#
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += MainWindow_Loaded;
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        ShowOpenFolderDialog();
    }

    private void ShowOpenFolderDialog()
    {
        RadOpenFolderDialog openFolderDialog = new RadOpenFolderDialog();
        openFolderDialog.Owner = this;
        openFolderDialog.ShowDialog();
        if (openFolderDialog.DialogResult == true)
        {
            string folderName = openFolderDialog.FileName;
        }
    }
}
```

> The **Owner** property holds a reference of the Window which owned the dialog. Before calling the **ShowDialog()** method, the **Owner** property should be set to ensure correct behavior. Ownership is established when this property is set.

## Enabling Multiple Selection

The dialog supports single and multiple selection modes. By default you can select only one folder at a time. To alter this you can set the **Multiselect** property of RadOpenFolderDialog.

**Example 3: Enable multiple selection**

```C#
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += MainWindow_Loaded;
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        ShowOpenFolderDialog();
    }

    private void ShowOpenFolderDialog()
    {
        RadOpenFolderDialog openFolderDialog = new RadOpenFolderDialog();
        openFolderDialog.Owner = this;
        openFolderDialog.Multiselect = true;
        openFolderDialog.ShowDialog();
    }
}
```

> caption Multiple selection

![WPF RadFileDialogs Multiple selection](https://www.telerik.com/products/wpf/documentation/assets/e2605ca2749e8c19a0a7a9e9f90fe5a6/radopenfolderdialog-02.png)

## Working with the Selected Folders

You can get the paths of the selected folders via the **FileName** and **FileNames** properties. Note that the properties are empty until the DialogResult is valid. When you open folder(s) the properties will return the corresponding directory paths.

You can get only the name of the selected folders, without the full path, via the **SafeFileNames** collection property.

**Example 3: Get the selected folder names**

```C#
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += MainWindow_Loaded;
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        ShowOpenFolderDialog();
    }

    private void ShowOpenFolderDialog()
    {
        RadOpenFolderDialog openFolderDialog = new RadOpenFolderDialog();
        openFolderDialog.Owner = this;
        openFolderDialog.ShowDialog();
        if (openFolderDialog.DialogResult == true)
        {
            string folderPath = openFolderDialog.FileName;
            IEnumerable<string> folderPaths = openFolderDialog.FileNames;
            IEnumerable<string> folderNames = openFolderDialog.SafeFileNames;
        }
    }
}
```

The **FileName** property can be set manually. This will change the value displayed in the selected file autocomplete box area. Note that setting this won't change the selected item in the list with the files.

## Saving the Last Used Directory

You can save the last used directory by setting the **RestoreDirectory** property of the RadOpenFolderDialog. After setting this property to **True** and opening a folder the **InitialDirectory** of this RadOpenFolderDialog instance will be set to the parent of the opened folder.

**Example 4: Set RestoreDirectory property**

```C#
RadOpenFolderDialog openFolderDialog = new RadOpenFolderDialog();
openFolderDialog.RestoreDirectory = true;
```

## See Also

* [Visual Structure](https://www.telerik.com/products/wpf/documentation/controls/radfiledialogs/visual-structure)
* [RadOpenFileDialog](https://www.telerik.com/products/wpf/documentation/controls/radfiledialogs/dialog-controls/radopenfiledialog)
* [RadSaveFileDialog](https://www.telerik.com/products/wpf/documentation/controls/radfiledialogs/dialog-controls/radsavefiledialog)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radfiledialogs/events)
