How to add contents of a.bin to b.bin in Powershell?
2 answers
If that doesn't work, there is always an approach like this:
function AppendFile([string]$Source, [string]$Target)
{
$TargetStream = [System.IO.File]::OpenWrite($Target);
$SourceStream = [System.IO.File]::OpenRead($Source);
$Buffer = New-Object Byte[] 8192;
$TargetStream.Seek(0, [System.IO.SeekOrigin]::End);
while (($BytesRead = $SourceStream.Read($Buffer, 0, $Buffer.Length)) -gt 0)
{
$TargetStream.Write($Buffer, 0, $BytesRead);
}
$TargetStream.Close();
$SourceStream.Close();
}
0
a source to share