> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# openfolderdialog

> Opens a Windows folder picker with Windows file picker with folder selection mode and returns the selected folder as a file item.

<div className="real-function-page">
  ```lua theme={null}
  openfolderdialog(options?: DialogOptions): FileSystemItem | nil
  ```

  ## Arguments

  <ParamField path={"options"} type={"DialogOptions"}>
    Optional table. For openfolderdialog, title and defaultPath are used. defaultPath is applied only when it resolves to an existing directory. extensionFilter is accepted by the shared dialog options parser but folder selection is enabled with folder selection mode.
  </ParamField>

  ## Returns

  <ResponseField name={"folder"} type={"FileSystemItem | nil"}>
    Selected folder item, or nil when the dialog is cancelled. Dialog failures throw Failed to open folder dialog.
  </ResponseField>

  ## Types

  ### DialogOptions

  Configures the Windows file or folder selection dialog.

  | Name               | Type                 | Required | Description                                                                      |
  | ------------------ | -------------------- | -------- | -------------------------------------------------------------------------------- |
  | `title`            | `string`             | No       | Sets the dialog window title.                                                    |
  | `defaultPath`      | `string`             | No       | Selects the directory shown when the dialog opens.                               |
  | `extensionFilter`  | `&#123;string&#125;` | No       | Limits selectable files to the listed extensions, with or without a leading dot. |
  | `suggestedName`    | `string`             | No       | Provides the initial file name in save dialogs.                                  |
  | `defaultExtension` | `string`             | No       | Sets the extension used when the entered file name has none.                     |

  ## Example

  Let the user select a folder and handle the selected folder item or cancellation.

  ```lua theme={null}
  local folder = openfolderdialog({
      title = "Choose a folder",
      defaultPath = ".",
  })

  if folder then
      print(folder:GetName())
      print(folder:IsFolder())
  else
      print("No folder selected")
  end
  ```
</div>
