> ## 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 مقبولة فقط اذا كانت resolve داخل 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>
