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

> Escreve Lua string bytes em um arquivo dentro do workspace, cria missing parent directories e substitui file contents se o arquivo ja existir.

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

  ## Aliases

  * `writefileasync`

  ## Argumentos

  <ParamField path={"path"} type={"string"} required>
    File path resolvido dentro do workspace apos separator normalization, workspace-boundary checks e filename/extension checks. Absolute paths so sao aceitos se resolverem dentro do workspace.
  </ParamField>

  <ParamField path={"content"} type={"string"} required>
    Lua string bytes para escrever. Os dados sao escritos em binary truncate mode; writefile nao adiciona newlines, BOM bytes, null terminators ou outros extra bytes.
  </ParamField>

  ## Exemplo

  Escreva bytes em um workspace file e substitua qualquer existing contents.

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

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

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