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

# savefiledialog

> Mo Windows save dialog thong qua Windows save dialog, ghi Lua string bytes duoc cung cap vao selected path va tra ve saved file duoi dang file item.

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

  ## Đối số

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes de ghi vao selected file. Tep duoc mo o binary truncate mode sau khi nguoi dung xac nhan path.
  </ParamField>

  <ParamField path={"options"} type={"DialogOptions"}>
    Optional table. savefiledialog dung title, defaultPath, extensionFilter, suggestedName va defaultExtension. extensionFilter la table gom extension strings; dau . hoac \*. o dau se bi loai bo truoc khi moi filter thanh \*.\<extension>. defaultExtension loai bo leading . characters truoc khi duoc truyen vao SetDefaultExtension.
  </ParamField>

  ## Giá trị trả về

  <ResponseField name={"file"} type={"FileSystemItem | nil"}>
    Saved file item, hoac nil khi dialog bi huy. Dialog or write failures se throw Failed to save file.
  </ResponseField>

  ## Kiểu

  ### DialogOptions

  Định cấu hình hộp thoại chọn tệp hoặc thư mục gốc.

  | Name               | Type                 | Required | Mô tả                                                                                              |
  | ------------------ | -------------------- | -------- | -------------------------------------------------------------------------------------------------- |
  | `title`            | `string`             | No       | Đặt tiêu đề cửa sổ hộp thoại.                                                                      |
  | `defaultPath`      | `string`             | No       | Chọn thư mục hiển thị khi hộp thoại mở ra.                                                         |
  | `extensionFilter`  | `&#123;string&#125;` | No       | Giới hạn các tệp có thể chọn ở các tiện ích mở rộng được liệt kê, có hoặc không có dấu chấm ở đầu. |
  | `suggestedName`    | `string`             | No       | Cung cấp tên tệp ban đầu trong hộp thoại lưu.                                                      |
  | `defaultExtension` | `string`             | No       | Đặt phần mở rộng được sử dụng khi tên tệp đã nhập không có.                                        |

  ## Ví dụ

  Ghi generated content vao path do nguoi dung chon va xu ly saved file item.

  ```lua theme={null}
  local saved = savefiledialog("Example output", {
      title = "Save output",
      suggestedName = "output.txt",
      defaultExtension = "txt",
      extensionFilter = { "txt" },
  })

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