来自Powershell的C#:get-content -Encoding Byte

时间:2017-05-03 14:44:19

标签: c# powershell

有没有人知道C#等同于powershells“get-content -Encoding Byte”?

我想转发这个:

Get-Content  $m1,$m2,$m3 -Enc Byte -Read 512 | Set-Content $m4 -Enc Byte

进入c#代码,不调用powershell进程。

1 个答案:

答案 0 :(得分:1)

CopyTo

稍微省力一点,这段代码可以推广到任意数量的输入文件,而不是三个。我已经将缓冲区大小设置为512以匹配PowerShell代码,但是你可能最好不要这样做,因此CopyTo可以使用自己的缓冲区大小。在PowerShell中,这是必要的,因为管道将以字节为单位进行操作,但$scope.list1{ Object 1, Object 2, Object 3} $scope.list2{ Object 4, Object 5, } 并不是那么天真。