C# 调用exe 传递参数



    System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo.FileName = Path.Combine(Server.MapPath("/"), "Office2Pdf.exe");


            proc.StartInfo.Arguments = string.Format("{0} {1}", officePath, pdfPath);
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            proc.StartInfo.CreateNoWindow = true;
            proc.StartInfo.RedirectStandardOutput = true;
            string output = string.Empty;
            if (proc.Start())
            {
                output = proc.StandardOutput.ReadToEnd();
                proc.WaitForExit();
                proc.Close();
            }
            else
                output = "转换失败";


  Process process = new Process();
           //process.StartInfo.WorkingDirectory = Application.StartupPath;
            process.StartInfo.FileName = dir;//example:1.bat
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardError = true;//开启出错返回信息
            process.StartInfo.RedirectStandardOutput = true;//开房输出返回信息
            process.Start();
            string strOUT = process.StandardOutput.ReadToEnd();//用于捕捉返回信息。
            string strERR = process.StandardError.ReadToEnd();



你可能感兴趣的:(C# 调用exe 传递参数)