# OpenFileDialog

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

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)
- [OpenFileDialog](/api/wisej.web/common-dialogs/wisej.web.openfiledialog)
Prompts the user to open a file from the server.

- C# - VB.NET

```csharp
public class OpenFileDialog : FileDialog
```

```visual
Public Class OpenFileDialog
    Inherits FileDialog
```

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.openfiledialog#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 [IFileSystemProvider](/api/wisej.core/general/wisej.core.ifilesystemprovider) to the [Roots](/api/wisej.web/common-dialogs/wisej.web.filedialog#roots) collection before showing the dialog.

## Constructors

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

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

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

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

## Properties

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

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

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

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets a value indicating whether the dialog box allows multiple files to be selected. (Default: `False` )

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

[String](https://docs.microsoft.com/dotnet/api/system.string) : Returns the file name and extension for the file selected in the dialog box. The file name does not include the path. (Default: `""` )

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

[String[]](https://docs.microsoft.com/dotnet/api/system.string) : Returns an array of file names and extensions for all the selected files in the dialog box. The file names do not include the path.

Default value is an empty array of strings- string[0]

## Methods

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

Opens the file selected by the user, with read-only permission. The file is specified by the [FileName](/api/wisej.web/common-dialogs/wisej.web.filedialog#filename) property.

**Returns:**[Stream](https://docs.microsoft.com/dotnet/api/system.io.stream) . A [Stream](https://docs.microsoft.com/dotnet/api/system.io.stream) that specifies the read-only file selected by the user.

**Throws:**

- [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)[FileName](/api/wisej.web/common-dialogs/wisej.web.filedialog#filename) is empty or null.

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

Resets all properties to their default values.
