调用exe传参格式

        private void button2_Click(object sender, EventArgs e)
        {

          //输入参数1

              if (textBox1.Text == "")
            {
                MessageBox.Show("请加载输入参数1!");
            }
            //输入参数2    
            else if (textBox4.Text == "")
            {
                MessageBox.Show("请加载输入参数2 !");
            }

            //输出路径1
            else if (textBox4.Text == "")
            {
                MessageBox.Show("请选择输出路径1!");
            }

            //输出路径2
            else if (textBox4.Text == "")
            {
                MessageBox.Show("请选择输出路径2!");
            }

            else
            {
                Process p_GF5plant = new Process();// 初始化新的进程
                p_GF5plant.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"D:\W\Debug\GF5plant.exe");
                p_GF5plant.StartInfo.Arguments = string.Format("{0} {1} {2} {3}", this.textBox1.Text, this.textBox4.Text, this.textBox2.Text, this.textBox3.Text);
                p_GF5plant.StartInfo.UseShellExecute = false;  // 是否使用外壳程序 
                p_GF5plant.StartInfo.CreateNoWindow = true;//是否在新窗口中启动该进程的值 
                p_GF5plant.StartInfo.RedirectStandardOutput = true;// 重定向输出流 

                //process.StartInfo.RedirectStandardError= true;  //重定向错误流 

                p_GF5plant.OutputDataReceived += new DataReceivedEventHandler(p_GF5plant_OutputDataReceived);
                p_GF5plant.Start();// 启动进程
                p_GF5plant.WaitForExit();// 等待退出
                p_GF5plant.BeginOutputReadLine();
            }

            MessageBox.Show("计算完成!");
        }

猜你喜欢

转载自blog.csdn.net/u010753302/article/details/79952804