# WriteBytesToFile (String filePath, ByteArray bytes)

| **Name**    | ***WriteBytesToFile***                                                                                                          |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Syntax      | WriteBytesToFile (String filePath, ByteArray bytes)                                                                             |
| Purpose     | To write bytes to a file.                                                                                                       |
| Description | Writes bytes to a file. Creates a new file and overwrites the file if it already exists.                                        |
| Return Type | Void                                                                                                                            |
| Parameters  | <p>filePath \[System.String] – Full path of the file</p><p>bytes \[System.Byte\[]] – A byte array to be written to the file</p> |

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FcFmgFId0faJlwm7Ex7AS%2F0.png?alt=media)

**Example**

In this example, we are passing the required parameters to the function transformation object using a *Variables* object and a *ToBytes* function transformation object. We will be writing the byte array, “48656C6C6F20576F726C64”, into a new, empty Test.txt file.

Where,

*filePath* = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Test.txt

*bytes* = 48656C6C6F20576F726C64

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FajgThDRGZ2JAhLEWCeEf%2F1.png?alt=media)

Right-click on the function transformation object and select *Preview Output.* While the *Data Preview* will not generate an output, a new file with the specfied name will be created at the specified loaction, and the provided byte array will be written to this file, after being converted into a string value.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FRO5PNAuETxpCsxEtzFDm%2F2.png?alt=media)


---

# 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://documentation.astera.com/astera-data-stack-v10/functions/files/writebytestofile-string-filepath-bytearray-bytes.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.
