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

> Записывает Lua string bytes в файл внутри workspace, создает 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>
    File path разрешается внутри workspace после separator normalization, workspace-boundary checks и filename/extension checks. 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>

  ## Пример

  Запишите bytes в workspace file и замените любые existing contents.

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

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

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