C# 如何在c中创建管道powershell#

C# 如何在c中创建管道powershell#,c#,powershell,pipeline,C#,Powershell,Pipeline,我正在尝试使用c中的powershell命令在文本文件前面插入一个简单的图表“m”# powershell中的功能版本: $path = 'mypath\file.txt' 'M' + (Get-Content $path -Raw) | Set-Content $path 电位转换 { ps.AddCommand("Get-Content"); ps.AddParameter(&quo

我正在尝试使用c中的powershell命令在文本文件前面插入一个简单的图表“m”#

powershell中的功能版本:

$path = 'mypath\file.txt'
'M' + (Get-Content $path -Raw) | Set-Content $path
电位转换

            {
                ps.AddCommand("Get-Content");
                ps.AddParameter("Path", 
               @"mypath\file.txt");

                ps.AddCommand("set-Content");
                ps.AddParameter("Value", "M");
                ps.AddParameter("NoNewline");
                ps.Invoke();
            }
我是新来的,我一点也不懂。。谢谢