ReadAllBytes
and WriteAllBytes
of the System.IO.File
class read and write a byte array from/to a file. $byte_array
) whose elements contain the ASCII codes of «Hello world.» and the writes this array into a file. [Byte[]] $byte_array = 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 46 [System.IO.File]::WriteAllBytes("$pwd/hello-world.txt", $byte_array)
System.Char
: [Byte[]] $byte_array = [System.IO.File]::ReadAllBytes("$pwd/hello-world.txt") foreach ($byte in $byte_array) { write-host ($byte -as [Char]) }