# FileDialog

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [CommonDialog](/api/wisej.web/common-dialogs/wisej.web.commondialog.md)
  * [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md)

Displays a dialog box from which the user can select a file.

{% tabs %}
{% tab title="C#" %}

```csharp
public class FileDialog : CommonDialog
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class FileDialog
    Inherits CommonDialog
```

{% endtab %}
{% endtabs %}

This class is abstract. The current implementations in Wisej are [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog.md) and [SaveFileDialog](/api/wisej.web/common-dialogs/wisej.web.savefiledialog.md). You can override this class or [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog.md) and [SaveFileDialog](/api/wisej.web/common-dialogs/wisej.web.savefiledialog.md) to add your own custom behavior and localization. You can:

* Override [PromptFileNotFound](#promptfilenotfound). It's called when the specified file doesn't exist and the property [CheckFileExists](#checkfileexists) is true.
* Override [CreateUI](#createui) to create your custom [Form](/api/wisej.web/containers/form.md) when the method [ShowDialog](/api/wisej.web/common-dialogs/wisej.web.commondialog.md#showdialog) is called.
* Set the [DialogTemplate](/api/wisej.web/common-dialogs/wisej.web.commondialog.md#dialogtemplate) to a [Form](/api/wisej.web/containers/form.md) class that has a constructor that accepts [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md) as the single argument to change the User Interface (UI) of the file dialog.
* Override [OnFileOk](#onfileok) to provide your custom implementation of the actions to execute when the user presses the OK button.

You must add at least one [FileSystemProvider](/api/wisej.core/general/wisej.core.filesystemprovider.md) to the [Roots](#roots) collection before showing the dialog.

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) FileDialog()

Initializes a new instance of [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) FileDialog(roots)

Initializes a new instance of [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md) using the initial *roots* .

| Name      | Type                                                                                 | Description                                                                                                                |
| --------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| **roots** | [IFileSystemProvider\[\]](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) | Initial file systems to load in the [FolderBrowserDialog](/api/wisej.web/common-dialogs/wisej.web.folderbrowserdialog.md). |

### ![](/files/hsR4ok3152WyAf8J2C1u) FileDialog(container)

Initializes a new instance of the [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md) extender with a specified container.

| Name          | Type                                                                                 | Description                                                                                                                                                                                                 |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **container** | [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) | An [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) that represents the container of the [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md) component. |

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) AddExtension

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the dialog box automatically adds an extension to a file name if the user omits the extension. (Default: `True`)

### ![](/files/hsR4ok3152WyAf8J2C1u) CheckFileExists

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the dialog box displays a warning if the user specifies a file name that does not exist. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) DefaultExtension

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the default file name extension. (Default: `""`)

### ![](/files/hsR4ok3152WyAf8J2C1u) FileName

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets a string containing the file name selected in the file dialog box. (Default: `""`)

### ![](/files/hsR4ok3152WyAf8J2C1u) FileNames

[String\[\]](https://docs.microsoft.com/dotnet/api/system.string): Returns the file names of all selected files in the dialog box.

### ![](/files/hsR4ok3152WyAf8J2C1u) FileSystem

[IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md): Returns the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) that contains the selected [FileName](#filename).

### ![](/files/hsR4ok3152WyAf8J2C1u) Filter

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. (Default: `""`)

### ![](/files/hsR4ok3152WyAf8J2C1u) FilterIndex

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns or sets the index of the filter currently selected in the file dialog box. (Default: `1`)

### ![](/files/hsR4ok3152WyAf8J2C1u) InitialDirectory

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the initial directory displayed by the file dialog box. (Default: `""`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Roots

[FileDialogRootCollection](/api/wisej.web/common-dialogs/wisej.web.filedialogrootcollection.md): List of root [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) file systems displayed by the FileDialog.

The Roots collection and the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) implementations allow the application to use arbitrary names mapped to a specific path. For example, the app may add a root object named "Documents" to "c:\users\[logged-user-id]\files\documents". Each user will see "Documents" as the root, but will also see only the files in the \[logged-user-id] directory.

### ![](/files/hsR4ok3152WyAf8J2C1u) ShowHelp

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the Help button is displayed in the file dialog box. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Title

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the file dialog box title. (Default: `""`)

## Methods

### ![](/files/lzopMboA31bVq8UIcbT3) CreateUI()

**Returns:** [Form](/api/wisej.web/containers/form.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) GetRoot(path)

Returns the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) that contains the specified *path* .

| Parameter | Type                                                          | Description                                                   |
| --------- | ------------------------------------------------------------- | ------------------------------------------------------------- |
| **path**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | Full path of the file to locate in on of the [Roots](#roots). |

**Returns:** [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md). The [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) that contains the specified *path* or null if not found.

### ![](/files/hsR4ok3152WyAf8J2C1u) MapPath(filePath)

Maps the virtual path to the corresponding physical path on the specific [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) implementation.

| Parameter    | Type                                                          | Description                                             |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------- |
| **filePath** | [String](https://docs.microsoft.com/dotnet/api/system.string) | Virtual path to map to the corresponding physical path. |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string). The physical path for the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider.md) implementation.

### ![](/files/lzopMboA31bVq8UIcbT3) OnFileOk(e)

Fires the [FileOk](#fileok) event.

| Parameter | Type                                                                                           | Description                                                                                                                    |
| --------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **e**     | [CancelEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.canceleventargs) | A [CancelEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.canceleventargs) that contains the event data. |

### ![](/files/hsR4ok3152WyAf8J2C1u) OnLoadPath(e)

Fires the [LoadPath](#loadpath) event.

| Parameter | Type                                                                                                  | Description                                                                                                                                  |
| --------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [FileDialogLoadPathEventArgs](/api/wisej.web/common-dialogs/wisej.web.filedialogloadpatheventargs.md) | A [FileDialogLoadPathEventArgs](/api/wisej.web/common-dialogs/wisej.web.filedialogloadpatheventargs.md) object that provides the event data. |

### ![](/files/hsR4ok3152WyAf8J2C1u) ProcessFileNames(fileNames)

Receives the file names selected by the user and validates them according to the properties set in the [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog.md) instance.

| Parameter     | Type                                                              | Description                               |
| ------------- | ----------------------------------------------------------------- | ----------------------------------------- |
| **fileNames** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | Array containing the selected file paths. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). True if the files have been validated and the dialog can close; otherwise false to keep the dialog open.

### ![](/files/lzopMboA31bVq8UIcbT3) PromptFileNotFound(fileName)

Informs the user that the file specified in *fileName* doesn't exist. You can override this method to provide your text and localization.

| Parameter    | Type                                                          | Description                          |
| ------------ | ------------------------------------------------------------- | ------------------------------------ |
| **fileName** | [String](https://docs.microsoft.com/dotnet/api/system.string) | Name of the file that doesn't exist. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Reset()

Resets all properties to their default values.

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) FileOk

[CancelEventHandler](https://docs.microsoft.com/dotnet/api/system.componentmodel.canceleventhandler) Fired when the user clicks on the Open or Save button on a file dialog box.

### ![](/files/hsR4ok3152WyAf8J2C1u) LoadPath

[FileDialogLoadPathEventHandler](/api/wisej.web/common-dialogs/wisej.web.filedialogloadpatheventhandler.md) Fired when the file dialog is loading a file or folder.

## Inherited By

| Name                                                                        | Description                                                            |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog.md) | Prompts the user to open a file from the server.                       |
| [SaveFileDialog](/api/wisej.web/common-dialogs/wisej.web.savefiledialog.md) | Prompts the user to select a location for saving a file on the server. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.filedialog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
