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

# writefile

> Ghi Lua string bytes vao mot tep ben trong workspace, tao missing parent directories va thay the file contents neu tep da ton tai.

<div className="real-function-page">
  ```lua theme={null}
  writefile(path: string, content: string)
  ```

  ## Alias

  * `writefileasync`

  ## Đối số

  <ParamField path={"path"} type={"string"} required>
    File path duoc resolve ben trong workspace sau separator normalization, workspace-boundary checks va filename/extension checks. Absolute paths chi duoc chap nhan neu resolve ben trong workspace.
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes de ghi. Du lieu duoc ghi o binary truncate mode; writefile khong them newlines, BOM bytes, null terminators hoac extra bytes khac.
  </ParamField>

  ## Ví dụ

  Ghi bytes vao workspace file va thay the moi existing contents.

  ```lua theme={null}
  local path = "examples/config.json"

  writefile(path, '{"enabled":true}')
  print(readfile(path))

  writefile(path, "")
  print(#readfile(path))
  ```
</div>
