日期:2014-05-18  浏览次数:20478 次

.net执行exe文件,并接受返回值的问题
如题
今天上司让做一个执行exe文件的程序,并通过exe文件的返回值进行其他相关的处理。


有一点不是很明白:exe文件怎么会有返回值;
      想了想所谓的返回值,是不是指exe文件的输出Console.Write(),Console.WriteLine();

根据自己的理解作了个测试程序,但是获取不到exe文件的返回值,希望大虾们给于帮助

                                                          谢谢


------------------------------------------------------
exe文件:
  public   static   void   Main(string[]   args)
  {
      if   (args.Length   ==   0)
      {
                str   =   "123456 ";
      }
      else
      {
                str   =   args[0].ToString();
      }
      Console.WriteLine(str);
    }

---------------------------------------------
asp.net
                System.Diagnostics.Process   p   =   new   System.Diagnostics.Process();
                p.StartInfo.UseShellExecute   =   false;
                p.StartInfo.RedirectStandardInput   =   true;
                p.StartInfo.RedirectStandardOutput   =   true;
                p.StartInfo.RedirectStandardError   =   true;
                p.StartInfo.CreateNoWindow   =   true;
                p.StartInfo.FileName   =   objLoadPath.ToString();
                p.StartInfo.Arguments   =   "test ";
                p.Start();
                string   output   =   p.StandardOutput.ReadToEnd().ToString();
                p.WaitForExit();




------解决方案--------------------
不可能的吧
------解决方案--------------------
public static string Main(string[] args)
{
if (args.Length == 0)
{
str = "123456 ";
}
else
{
str = args[0].ToString();
}
return str;
}
从main()控制台返回字符串