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

> workspace 内のファイルへ Lua string bytes を書き込み、missing parent directories を作成し、ファイルがすでに存在する場合は file contents を置き換えます。

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

  ## エイリアス

  * `writefileasync`

  ## 引数

  <ParamField path={"path"} type={"string"} required>
    separator normalization、workspace-boundary checks、filename/extension checks の後に workspace 内へ解決される File path。Absolute paths は workspace 内に解決される場合だけ受け入れられます。
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    書き込む Lua string bytes。データは binary truncate mode で書き込まれます。writefile は newlines、BOM bytes、null terminators、その他の extra bytes を追加しません。
  </ParamField>

  ## 例

  workspace file に bytes を書き込み、existing contents を置き換えます。

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

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

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