如题
今天上司让做一个执行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();

解决方案 »

  1.   

    你的意思是指什么,是p.StandardOutput.ReadToEnd()获取不到exe的任何信息吗?能把你的观点说的详细些么?
    谢谢
      

  2.   

    public static string Main(string[] args)
     {
       if (args.Length == 0)
       {
            str = "123456";
       }
       else
       {
            str = args[0].ToString();
       }
              return str;
      }
    从main()控制台返回字符串
      

  3.   

    按照你这样的方式我可以得到结果啊,会不会是有可能你的exe程序有问题?