> ## 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 picker 経由で Windows file-open dialog を開き、選択されたファイルを 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 は extension strings の table です。各 filter が \*.\<extension> になる前に、先頭の . または \*. は削除されます。
  </ParamField>

  ## 戻り値

  <ResponseField name={"file"} type={"FileSystemItem | nil"}>
    Selected file item。dialog が cancel された場合、または selected filesystem path が返らない場合は nil。Dialog failures は Failed to open file dialog を throw します。
  </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>
