C# 调用exe 传参 ,并获取打印值

来源:互联网 发布:淘宝订单险 编辑:程序博客网 时间:2024/05/22 14:19
 调用方法:
string baseName = System.IO.Directory.GetCurrentDirectory();
            // baseName+"/"
            // string fileName = @"C:\Users\59930\Desktop\20170605\WindowsFormsApp1\WindowsFormsApp1\WindowsFormsApp1\bin\x86\Debug\WindowsFormsApp1.exe";
            string fileName = baseName + @"\CardRead.exe";
            string para = "1.exe " + code;
          
            Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = fileName;
            p.StartInfo.CreateNoWindow = true;
            p.StartInfo.Arguments = para;//参数以空格分隔,如果某个参数为空,可以传入””  
            p.Start();
            p.WaitForExit();
            string output = p.StandardOutput.ReadToEnd();



调用的exe 返回值中写
Console.Write(mmma); 
原创粉丝点击