# Write file

![](/files/2Mg8xN7Ry55g3cAK7OiQ)

Element rewriting the content of a file

![](/files/AsTfWcdWQAtvpBqEHcg1)

Properties

\- Encoding: \[String] Encoding used in a file (utf-8) '<https://docs.microsoft.com/ru-ru/dotnet/api/system.text.encoding>'

\- File path\*: \[String] Path to a file to be written (c:\folder\file.txt)

\- Text: \[String] Text to be written to a file

\- Array: \[byte\[]] Binary data recorded in a file

\- Image: \[System.Drawing.Bitmap] Image to be written to a file

```
C#
System.IO.File.WriteAllLines(@"C:\text.txt", new List<string>() { "New text" });
System.IO.File.WriteAllText(@"C:\text.txt", "New text");
System.IO.File.WriteAllBytes(@"C:\bytes.txt", new byte[0]);

Python
System.IO.File.WriteAllLines("C:\\text.txt", List[String](["New text"]));
System.IO.File.WriteAllText("C:\\text.txt", "New text");
System.IO.File.WriteAllBytes("C:\\bytes.txt", Array[Byte]([]));

JavaScript
var host = new _lib.Microsoft.ClearScript.HostFunctions();
var items = host.newObj(_lib.System.Collections.Generic.List(_lib.System.String));
items.Add("New text");
_lib.System.IO.File.WriteAllLines("C:\\text.txt", items);
_lib.System.IO.File.WriteAllText("C:\\text.txt", "New text");
var bytes = host.newObj(_lib.System.Collections.Generic.List(_lib.System.Byte));
_lib.System.IO.File.WriteAllBytes("C:\\bytes.txt", bytes.ToArray());
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://astro-rpa.gitbook.io/astro-rpa-user-guide/g_elements/el_basic/els_files/el_files_write.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
