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

> เปิด Windows save dialog ผ่าน Windows save dialog เขียน Lua string bytes ที่ส่งเข้ามาไปยัง selected path และคืน saved file เป็น file item

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

  ## Arguments

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes ที่จะเขียนไปยัง selected file. ไฟล์จะถูกเปิดใน binary truncate mode หลังจากผู้ใช้ยืนยัน path.
  </ParamField>

  <ParamField path={"options"} type={"DialogOptions"}>
    Optional table. savefiledialog ใช้ title, defaultPath, extensionFilter, suggestedName และ defaultExtension. extensionFilter คือ table ของ extension strings; . หรือ \*. ที่อยู่ต้นค่าจะถูกลบก่อนที่แต่ละ filter จะกลายเป็น \*.\<extension>. defaultExtension ลบ leading . characters ก่อนส่งไปยัง SetDefaultExtension.
  </ParamField>

  ## Returns

  <ResponseField name={"file"} type={"FileSystemItem | nil"}>
    Saved file item หรือ nil เมื่อ dialog ถูกยกเลิก. Dialog or write failures จะ throw Failed to save file.
  </ResponseField>

  ## Types

  ### DialogOptions

  กำหนดค่ากล่องโต้ตอบการเลือกไฟล์หรือโฟลเดอร์ดั้งเดิม

  | Name | Type | Required | คำอธิบาย |
  | - | - | - | - |
  | `title` | `string` | No | ตั้งชื่อหน้าต่างข้อความโต้ตอบ |
  | `defaultPath` | `string` | No | เลือกไดเร็กทอรีที่แสดงเมื่อกล่องโต้ตอบเปิดขึ้น |
  | `extensionFilter` | `&#123;string&#125;` | No | จำกัดไฟล์ที่เลือกไว้เฉพาะนามสกุลที่อยู่ในรายการ โดยมีหรือไม่มีจุดนำหน้าก็ได้ |
  | `suggestedName` | `string` | No | ระบุชื่อไฟล์เริ่มต้นในกล่องโต้ตอบบันทึก |
  | `defaultExtension` | `string` | No | ตั้งค่านามสกุลที่ใช้เมื่อชื่อไฟล์ที่ป้อนไม่มี |

  ## ตัวอย่าง

  เขียน generated content ไปยัง path ที่ผู้ใช้เลือก แล้วจัดการ 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>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.