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

> Escribe Lua string bytes en un archivo dentro del workspace, crea missing parent directories y reemplaza file contents si el archivo ya existe.

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

  ## Alias

  * `writefileasync`

  ## Argumentos

  <ParamField path={"path"} type={"string"} required>
    File path resuelto dentro del workspace despues de separator normalization, workspace-boundary checks y filename/extension checks. Absolute paths solo se aceptan si resuelven dentro del workspace.
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes que se escriben. Los datos se escriben en binary truncate mode; writefile no agrega newlines, BOM bytes, null terminators ni otros extra bytes.
  </ParamField>

  ## Ejemplo

  Escribe bytes en un workspace file y reemplaza cualquier existing contents.

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

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

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