调用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("计算完成!");
        }

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值