首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 得到命令行执行结果为空白,指点

2013-11-14 
C# 得到命令行执行结果为空白,在线等指点使用以下代码执行p1.exe程序,希望得到返回值Process p new Proc

C# 得到命令行执行结果为空白,在线等指点
使用以下代码执行p1.exe程序,希望得到返回值
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";      
p.StartInfo.Arguments = "/c  p1.exe" ;           
p.StartInfo.UseShellExecute = false;            
p.StartInfo.RedirectStandardInput = true;              
p.StartInfo.RedirectStandardOutput = true;  
p.StartInfo.RedirectStandardError = true;  
p.StartInfo.CreateNoWindow = true;         
p.Start();          
string g = p.StandardOutput.ReadLine();
p.WaitForExit();
string Flag = p.StandardOutput.ReadLine();
MessageBox.Show(g + "  ew " + Flag + "  cc");
无论在
p.WaitForExit();
前后读取输出流,都是空白,不解?

p1.exe代码:
class Program
    {
        static int Main(string[] args)
        {
            int  kk = 998;
            System.Threading.Thread.Sleep(6000);
            return kk;
        }
    }
希望得到998返回值,环境:win7 x64 ,请指点
[解决办法]
尼玛,p1.exe本来就什么都不显示,你能奢求它打印什么呢
[解决办法]
Console.Write(kk);

热点排行