Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.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#在第一次执行后更新(dos)进程_C#_Process - Fatal编程技术网

c#在第一次执行后更新(dos)进程

c#在第一次执行后更新(dos)进程,c#,process,C#,Process,我正在尝试用c语言制作一个ADB工具来处理我的手机输入/输出,目前,我可以通过为每个命令创建一个独立的进程来执行单行,但是否可以在命令执行后更新进程,以便我只创建一个进程来处理shell命令) 当前代码: Dos执行: internal Process getShell() { Process p = new Process(); p.StartInfo.FileName = "cmd.exe";

我正在尝试用c语言制作一个ADB工具来处理我的手机输入/输出,目前,我可以通过为每个命令创建一个独立的进程来执行单行,但是否可以在命令执行后更新进程,以便我只创建一个进程来处理shell命令)

当前代码:

Dos执行:

        internal Process getShell()
        {
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.Arguments = $"/C adb shell";
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.UseShellExecute = false;
            p.Start();

            return p;
        }

# What i need (dont know the correct method for the new command)
var shell = getShell()
shell.command = new_command_str;
shell.Refresh(); 

# Shell output handeling (print for test)
Console.WriteLine(shell.StandardOutput.ReadToEnd());


启动进程有一个标准输入(可以使用Console.ReadLine()读取)和标准输出(可以使用Console.Writeline写入)。标准输入/输出是流,可以在代码运行时动态更新。