# SaveFileDialog

Namespace: **Wisej.Web**

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

* [CommonDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.commondialog)
  * [FileDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.filedialog)
    * [SaveFileDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.savefiledialog)

Prompts the user to select a location for saving a file on the server.

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

```csharp
public class SaveFileDialog : FileDialog
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

You can:

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

## Constructors

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) SaveFileDialog()

Initializes a new instance of [SaveFileDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.savefiledialog).

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) SaveFileDialog(container)

Initializes a new instance of the [SaveFileDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.savefiledialog) 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 [SaveFileDialog](https://docs.wisej.com/api/wisej.web/common-dialogs/wisej.web.savefiledialog) component. |

## Properties

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) CreatePrompt

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets a value indicating whether the dialog box prompts the user for permission to create a file, if the file specified file does not exist. (Default: `False`)

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) OverwritePrompt

[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 already exists. (Default: `True`)

## Methods

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) OpenFile()

Opens the file with read/write permission selected by the user.

**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/write file selected by the user.

**Throws:**

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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) ProcessFileNames(fileNames)

Receives the file names selected by the user and validates them according to the properties set in the [FileDialog](https://docs.wisej.com/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.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) PromptFileCreate(fileName)

Asks the user's permission to create the specified *fileName* .

| Parameter    | Type                                                          | Description          |
| ------------ | ------------------------------------------------------------- | -------------------- |
| **fileName** | [String](https://docs.microsoft.com/dotnet/api/system.string) | File name to create. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). True if the user confirms to create the file.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-9bf7fa01e02f4da0f9ef90d3b049ae43e664919e%2Fprotected.png?alt=media) PromptFileOverwrite(fileName)

Asks the user's permission to overwrite the specified *fileName* .

| Parameter    | Type                                                          | Description             |
| ------------ | ------------------------------------------------------------- | ----------------------- |
| **fileName** | [String](https://docs.microsoft.com/dotnet/api/system.string) | File name to overwrite. |

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean). True if the user confirms to overwrite the file.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Reset()

Resets all dialog box options to their default values.
