> ## 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.

# openfiledialog

> Открывает Windows file-open dialog через Windows file picker и возвращает выбранный файл как file item.

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

  ## Аргументы

  <ParamField path={"options"} type={"DialogOptions"}>
    Optional table. Для openfiledialog используются title, defaultPath и extensionFilter. extensionFilter это table из extension strings; начальные . или \*. удаляются перед тем, как каждый filter становится \*.\<extension>.
  </ParamField>

  ## Возвраты

  <ResponseField name={"file"} type={"FileSystemItem | nil"}>
    Selected file item или nil, если dialog отменен или selected filesystem path не возвращен. Dialog failures выбрасывают Failed to open file dialog.
  </ResponseField>

  ## Типы

  ### DialogOptions

  Настраивает собственный диалог выбора файла или папки.

  | Name               | Type                 | Required | Описание                                                                                 |
  | ------------------ | -------------------- | -------- | ---------------------------------------------------------------------------------------- |
  | `title`            | `string`             | No       | Устанавливает заголовок диалогового окна.                                                |
  | `defaultPath`      | `string`             | No       | Выбирает каталог, отображаемый при открытии диалогового окна.                            |
  | `extensionFilter`  | `&#123;string&#125;` | No       | Ограничивает выбираемые файлы перечисленными расширениями с точкой в начале или без нее. |
  | `suggestedName`    | `string`             | No       | Предоставляет исходное имя файла в диалоговых окнах сохранения.                          |
  | `defaultExtension` | `string`             | No       | Устанавливает расширение, используемое, если введенное имя файла не имеет его.           |

  ## Пример

  Откройте file picker и обработайте selected file item или cancellation.

  ```lua theme={null}
  local file = openfiledialog({
      title = "Choose a configuration",
      defaultPath = ".",
      extensionFilter = { "json", "txt" },
  })

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