# FileDialog

URL: https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.filedialog

Version: 4.1
Namespace: **Wisej.Web**

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

- [CommonDialog](/api/wisej.web/common-dialogs/wisej.web.commondialog)
- [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog)
Displays a dialog box from which the user can select a file.

- C# - VB.NET

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

```visual
Public Class FileDialog
    Inherits CommonDialog
```

This class is abstract. The current implementations in Wisej are [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog) and [SaveFileDialog](/api/wisej.web/common-dialogs/wisej.web.savefiledialog) .

You can override this class or [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog) and [SaveFileDialog](/api/wisej.web/common-dialogs/wisej.web.savefiledialog) to add your own custom behavior and localization.

You can:

- Override [PromptFileNotFound](/api/wisej.web/common-dialogs/wisej.web.filedialog) . It's called when the specified file doesn't exist and the property [CheckFileExists](/api/wisej.web/common-dialogs/wisej.web.filedialog#checkfileexists) is true.
- Override [CreateUI](/api/wisej.web/common-dialogs/wisej.web.filedialog#createui) to create your customForm when the method [ShowDialog](/api/wisej.web/common-dialogs/wisej.web.commondialog#showdialog) is called.
- Set the [DialogTemplate](/api/wisej.web/common-dialogs/wisej.web.commondialog#dialogtemplate) to aForm class that has a constructor that accepts [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog) as the single argument to change the User Interface (UI) of the file dialog.
- Override [OnFileOk](/api/wisej.web/common-dialogs/wisej.web.filedialog) 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) to the [Roots](/api/wisej.web/common-dialogs/wisej.web.filedialog#roots) collection before showing the dialog.

## Constructors

### ![Instance member](/img/api/instance.png) FileDialog()

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

### ![Instance member](/img/api/instance.png) FileDialog(roots)

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

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

### ![Instance member](/img/api/instance.png) FileDialog(container)

Initializes a new instance of the [FileDialog](/api/wisej.web/common-dialogs/wisej.web.filedialog) 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) component. 

## Properties

### ![Instance member](/img/api/instance.png) 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` )

### ![Instance member](/img/api/instance.png) 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` )

### ![Instance member](/img/api/instance.png) DefaultExtension

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

### ![Instance member](/img/api/instance.png) 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: `""` )

### ![Instance member](/img/api/instance.png) FileNames

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

### ![Instance member](/img/api/instance.png) FileSystem

[IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) : Returns the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) that contains the selected [FileName](/api/wisej.web/common-dialogs/wisej.web.filedialog#filename) .

### ![Instance member](/img/api/instance.png) 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: `""` )

### ![Instance member](/img/api/instance.png) 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` )

### ![Instance member](/img/api/instance.png) InitialDirectory

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

### ![Instance member](/img/api/instance.png) Roots

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

The Roots collection and the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) 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.

### ![Instance member](/img/api/instance.png) 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` )

### ![Instance member](/img/api/instance.png) Title

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

## Methods

### ![Protected member](/img/api/protected.png) CreateUI()

**Returns:**Form .

### ![Instance member](/img/api/instance.png) GetRoot(path)

Returns the [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) 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](/api/wisej.web/common-dialogs/wisej.web.filedialog#roots) . 

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

### ![Instance member](/img/api/instance.png) MapPath(filePath)

Maps the virtual path to the corresponding physical path on the specific [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) 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) implementation.

### ![Protected member](/img/api/protected.png) OnFileOk(e)

Fires the [FileOk](/api/wisej.web/common-dialogs/wisej.web.filedialog#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. 

### ![Instance member](/img/api/instance.png) OnLoadPath(e)

Fires the [LoadPath](/api/wisej.web/common-dialogs/wisej.web.filedialog#loadpath) event.

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

### ![Instance member](/img/api/instance.png) 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) 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.

### ![Protected member](/img/api/protected.png) 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. 

### ![Instance member](/img/api/instance.png) Reset()

Resets all properties to their default values.

## Events

### ![Instance member](/img/api/instance.png) 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.

### ![Instance member](/img/api/instance.png) LoadPath

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

## Inherited By

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