如何将TextBox解析为运行exe的参数

时间:2016-09-25 03:03:00

标签: c#

我需要将文本框中的登录名和密码解析为参数以运行exe

 private void button1_Click(object sender, EventArgs e)
    {


        string username = textBox1.Text;
        string password = textBox2.Text;

        Process p = new Process();
        p.StartInfo.FileName = "Main.exe";
        p.StartInfo.Arguments = "-IFZUpdatedOk_K0 -gna -login @username -pwd  @password";
        p.Start();
        p.WaitForExit();


     //   System.Diagnostics.Process.Start("Main.exe", " -IFZUpdatedOk_K0 -gna -login email@email.com -pwd mypassword");
    }``

1 个答案:

答案 0 :(得分:1)

使用

p.StartInfo.Arguments = "-IFZUpdatedOk_K0 -gna -login " + username + " -pwd " + password;

p.StartInfo.Arguments = String.Format("-IFZUpdatedOk_K0 -gna -login {0} -pwd  {1}"), usernmae, password);