Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何启动单个进程,将一个输出导入另一个输出?_C#_Process - Fatal编程技术网

C# 如何启动单个进程,将一个输出导入另一个输出?

C# 如何启动单个进程,将一个输出导入另一个输出?,c#,process,C#,Process,如问题所述,我正试图使用c#进程库从单个进程调用启动两个进程 例如,我想运行以下内容: application1 "arg1" "arg2" | application2 "arg1". 目前,我的设置如下: ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Arguments = SEEBELOW; startInfo.FileName = FIRSTAPPLICATIONLOCATION; startInfo.R

如问题所述,我正试图使用c#进程库从单个进程调用启动两个进程

例如,我想运行以下内容:

application1 "arg1" "arg2" | application2 "arg1".
目前,我的设置如下:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = SEEBELOW;
startInfo.FileName = FIRSTAPPLICATIONLOCATION;

startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;

Process proc = new Process();
proc.StartInfo = startInfo;
proc.Start();

其中,进程文件名为“application1”,而“application1”的参数为“arg1”arg2|“application2”arg1“

管道
|
由命令处理器解释,因此如果要使用管道重定向,则需要调用命令处理器
cmd.exe/k app1.exe args | app2.exe args
谢谢Dan。我可以确认一下,我会这样做:startInfo.Filename=“C:\WINDOWS\system32\cmd.exe”;startInfo.Arguments=“/k app1.exe args | app2.exe args”;对我来说这是个好的开始。试试看,啊,伙计,丹欧。你不知道你是如何让我免于最后期限的。谢谢你,祝你今天愉快