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
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.
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
filePath [System.String] – Full path of the file
bytes [System.Byte[]] – A byte array to be written to the file