如何转换ctrl+z为字符串?
我将此作为AT COMMAND发送到此计算机的连接设备.
基本上,我只是将一些字符放在字符串中以及ctrl+z字符串中
我很难解读有关Process.StandardOutpout的MSDN文档,以了解Read(Char [],Int32,Int32)方法是否阻塞.我的理解是它不应该阻塞,但是当我将RedirectStandardInput设置为true时它似乎就是这样.
有没有人有这方面的经验; 或者对我遇到的问题有一些解释?
这里的上下文是我不想等待整行(即使用行终止符),或者在读取标准输出之前退出进程.另外我不想使用回调.我想在进程写入时同步读取StdOut.
这是我的代码的简化版本:
string command = @"C:\flex_sdks\flex_sdk_4.5.1.21328\bin\fcsh.exe";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = false; # <-- if I set this to true, then
# the program hangs on
# p.StandardOutput.Read later on
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = command;
p.Start();
StringBuilder sb_stdout = new StringBuilder(1024);
char[] buffer = new char[64];
int nb_bytes_read;
while (true) {
do {
nb_bytes_read = p.StandardOutput.Read(buffer, 0, buffer.Length);
sb_stdout.Append(new string(buffer, 0, nb_bytes_read));
} while …Run Code Online (Sandbox Code Playgroud)