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