# OpenFileDialog

Namespace: **Wisej.Web**

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

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

Prompts the user to open a file from the server.

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

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

You can:

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

## Constructors

### ![](/files/uCY6T77rh488FWHzpJ6P)OpenFileDialog()

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

### ![](/files/uCY6T77rh488FWHzpJ6P)OpenFileDialog(container)

Initializes a new instance of the [OpenFileDialog](/api/v3.0/wisej.web/common-dialogs/wisej.web.openfiledialog.md) extender with a specified container.

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

## Properties

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

[Boolean](https://docs.microsoft.com/en-us/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.

### ![](/files/uCY6T77rh488FWHzpJ6P)Multiselect

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

### ![](/files/uCY6T77rh488FWHzpJ6P)SafeFileName

[String](https://docs.microsoft.com/en-us/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.

### ![](/files/uCY6T77rh488FWHzpJ6P)SafeFileNames

[String\[\]](https://docs.microsoft.com/en-us/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.

## Methods

### ![](/files/uCY6T77rh488FWHzpJ6P)OpenFile()

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

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

**Throws:**

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

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

Resets all properties to their default values.


---

# 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/v3.0/wisej.web/common-dialogs/wisej.web.openfiledialog.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.
