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

> Schreibt Lua string bytes in eine Datei innerhalb des workspace, erstellt missing parent directories und ersetzt die file contents, wenn die Datei bereits existiert.

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

  ## Aliase

  * `writefileasync`

  ## Argumente

  <ParamField path={"path"} type={"string"} required>
    File path, der nach separator normalization, workspace-boundary checks und filename/extension checks innerhalb des workspace aufgeloest wird. Absolute paths werden nur akzeptiert, wenn sie innerhalb des workspace aufgeloest werden.
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes, die geschrieben werden. Die Daten werden im binary truncate mode geschrieben; writefile fuegt keine newlines, BOM bytes, null terminators oder andere extra bytes hinzu.
  </ParamField>

  ## Beispiel

  Schreibe bytes in eine workspace file und ersetze alle existing contents.

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

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

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