# 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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/OouVzsQuzL5j4WLj9szg/0.png)

**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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/wLOZzkvjK4PL1FGQXp9D/1.png)

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://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/iLRh4HjspC1e85SYpUZD/2.png)
