I work with large text files on a regular basis. In this case, I needed to generate a header for each file, but, add a small snippet of binary data. The hex characters, 0x0D,0x0A,0x0C, are common control characters. In this case, I needed to add a two line text string, the control characters, then, the remaining content of an original file. My first attempts to add binary data did not fare well, so, I went back to one of my favorite links:
PowerShell Byte Array And Hex Functions
For whatever reason I had never realized the Add-Content cmdlet existed, so, I dug into that one, and, came up with this approach. In the example below I have highlighted the two key lines in yellow.
0 comments:
Post a Comment