Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Calling external application with arbitary input parameters

Calling external application with arbitary input parameters

Scheduled Pinned Locked Moved C#
csharpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eyungwah
    wrote on last edited by
    #1

    Hello All: I'm using C#.Net. I have three TextBox forms A,B,C waiting for the input from the user. I would like to call the external application which will include these inputs parameter from user's Input from TextBox A,B and C. Here is part of my code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\PushCase"; procInfo.FileName = "PushCase.exe"; procInfo.Arguments = tb_params.Text; // since I have three separates TextBox A,B,C. How do I make it into // single parameter?? proc = System.Diagnostics.Process.Start(procInfo); Thanks in advance!

    C T M 3 Replies Last reply
    0
    • E Eyungwah

      Hello All: I'm using C#.Net. I have three TextBox forms A,B,C waiting for the input from the user. I would like to call the external application which will include these inputs parameter from user's Input from TextBox A,B and C. Here is part of my code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\PushCase"; procInfo.FileName = "PushCase.exe"; procInfo.Arguments = tb_params.Text; // since I have three separates TextBox A,B,C. How do I make it into // single parameter?? proc = System.Diagnostics.Process.Start(procInfo); Thanks in advance!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can use Process.Start, and put the parameters on the command line, comma seperated.  Of course, the app you're calling needs to expect them, in that order.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      1 Reply Last reply
      0
      • E Eyungwah

        Hello All: I'm using C#.Net. I have three TextBox forms A,B,C waiting for the input from the user. I would like to call the external application which will include these inputs parameter from user's Input from TextBox A,B and C. Here is part of my code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\PushCase"; procInfo.FileName = "PushCase.exe"; procInfo.Arguments = tb_params.Text; // since I have three separates TextBox A,B,C. How do I make it into // single parameter?? proc = System.Diagnostics.Process.Start(procInfo); Thanks in advance!

        T Offline
        T Offline
        Tyler45
        wrote on last edited by
        #3

        For ex., if you use internet explorer with a parameter System.Diagnostics.Process.Start("IExplore.exe","http://10.109.25.15/TouchScreen/Test/index.htm");

        1 Reply Last reply
        0
        • E Eyungwah

          Hello All: I'm using C#.Net. I have three TextBox forms A,B,C waiting for the input from the user. I would like to call the external application which will include these inputs parameter from user's Input from TextBox A,B and C. Here is part of my code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\PushCase"; procInfo.FileName = "PushCase.exe"; procInfo.Arguments = tb_params.Text; // since I have three separates TextBox A,B,C. How do I make it into // single parameter?? proc = System.Diagnostics.Process.Start(procInfo); Thanks in advance!

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, You just have to set a " " (space) between the Text properties. Like this:

          procInfo.Arguments = tbA.Text + " " + tbB.Text + " " + tbC.Text;

          Your Arguments would be:

          [STAThread]
          public static void Main(string [] Args)
          {
          if(Args.Length == 3) //In your case true (If there isn't a empty string of course)
          {
          }

          for(int x=0;x<=Args.Length;x++)
          {
              //Args\[x\]
          }
          

          }

          All the best, Martin

          E 2 Replies Last reply
          0
          • M Martin 0

            Hello, You just have to set a " " (space) between the Text properties. Like this:

            procInfo.Arguments = tbA.Text + " " + tbB.Text + " " + tbC.Text;

            Your Arguments would be:

            [STAThread]
            public static void Main(string [] Args)
            {
            if(Args.Length == 3) //In your case true (If there isn't a empty string of course)
            {
            }

            for(int x=0;x<=Args.Length;x++)
            {
                //Args\[x\]
            }
            

            }

            All the best, Martin

            E Offline
            E Offline
            Eyungwah
            wrote on last edited by
            #5

            Thank you guys for your help!

            1 Reply Last reply
            0
            • M Martin 0

              Hello, You just have to set a " " (space) between the Text properties. Like this:

              procInfo.Arguments = tbA.Text + " " + tbB.Text + " " + tbC.Text;

              Your Arguments would be:

              [STAThread]
              public static void Main(string [] Args)
              {
              if(Args.Length == 3) //In your case true (If there isn't a empty string of course)
              {
              }

              for(int x=0;x<=Args.Length;x++)
              {
                  //Args\[x\]
              }
              

              }

              All the best, Martin

              E Offline
              E Offline
              Eyungwah
              wrote on last edited by
              #6

              Thanks again Martin! I have the following code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\dc\\bin"; // procInfo.FileName = "scu.exe"; procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " "; proc = System.Diagnostics.Process.Start(procInfo); I have a Browse button which is the user will select its parameter for "tb_params2.Text". Question - If I wanted to have more than one parameter display on "tb_params.Text" TextBox when the user select multiple parameters from the Browse Button. What Common Control Box do I need to display a multiple selection?? Thanks again for ur help.

              M 1 Reply Last reply
              0
              • E Eyungwah

                Thanks again Martin! I have the following code: System.Diagnostics.Process proc; //Declare New Process System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.WorkingDirectory = "C:\\dc\\bin"; // procInfo.FileName = "scu.exe"; procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " "; proc = System.Diagnostics.Process.Start(procInfo); I have a Browse button which is the user will select its parameter for "tb_params2.Text". Question - If I wanted to have more than one parameter display on "tb_params.Text" TextBox when the user select multiple parameters from the Browse Button. What Common Control Box do I need to display a multiple selection?? Thanks again for ur help.

                M Offline
                M Offline
                Martin 0
                wrote on last edited by
                #7

                Hello, Just for info:

                Eyungwah wrote:

                procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " ";

                I think that you don't need '+ " ";' this. But now to your question: The TextBox would be able to show multiline text if you take care of properties like "Multiline"(true) and "AutoSize"(false). You would have to add a new line between your selected texts. Like:

                tb_params.Text = stringselection1 + System.Enviroment.NewLine + stringselection2;

                Instead I would recommend the ListBox. The "Items" property is what you need there. Like:

                lb_params.Items.Add(stringselection1);

                So if you have a collection of selected parameters you would do:

                for(int x=0;x

                All the best,

                Martin

                E 1 Reply Last reply
                0
                • M Martin 0

                  Hello, Just for info:

                  Eyungwah wrote:

                  procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " ";

                  I think that you don't need '+ " ";' this. But now to your question: The TextBox would be able to show multiline text if you take care of properties like "Multiline"(true) and "AutoSize"(false). You would have to add a new line between your selected texts. Like:

                  tb_params.Text = stringselection1 + System.Enviroment.NewLine + stringselection2;

                  Instead I would recommend the ListBox. The "Items" property is what you need there. Like:

                  lb_params.Items.Add(stringselection1);

                  So if you have a collection of selected parameters you would do:

                  for(int x=0;x

                  All the best,

                  Martin

                  E Offline
                  E Offline
                  Eyungwah
                  wrote on last edited by
                  #8

                  Thanks again Mark for your replied. I have a Browse button. If I created Four TextBox form. Everytime I Browse and select the file it always show the same file on all of those four TextBox. Here's my code: OpenFileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { tb_params2.Text = dlg.FileName; tb_params3.Text = dlg.FileName; tb_params4.Text = dlg.FileName; tb_params5.Text = dlg.FileName; } My goal is to have a Browse button that would navigate by a user and selected any file, then it displays that file on "tb_params2.Text" TextBox individually. I have created four TextBox and I wanted the file that was selected throught the Browse displayed on the TextBox accordingingly.. Could you please help me how to do that? Thanks

                  M 1 Reply Last reply
                  0
                  • E Eyungwah

                    Thanks again Mark for your replied. I have a Browse button. If I created Four TextBox form. Everytime I Browse and select the file it always show the same file on all of those four TextBox. Here's my code: OpenFileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { tb_params2.Text = dlg.FileName; tb_params3.Text = dlg.FileName; tb_params4.Text = dlg.FileName; tb_params5.Text = dlg.FileName; } My goal is to have a Browse button that would navigate by a user and selected any file, then it displays that file on "tb_params2.Text" TextBox individually. I have created four TextBox and I wanted the file that was selected throught the Browse displayed on the TextBox accordingingly.. Could you please help me how to do that? Thanks

                    M Offline
                    M Offline
                    Martin 0
                    wrote on last edited by
                    #9

                    Hello, Is it a question of multi selection? In this case you should make your code dynamic and hold the references of your TextBoxes in a Hashtable.

                    	private Hashtable AllTextBoxes = new Hashtable();
                    
                                //constructor code
                    
                    		AllTextBoxes.Add(0, textBox1);
                    		AllTextBoxes.Add(1, textBox2);
                                        //... 
                                        //You could make it more dynamic with a foreach(Control c in this.Controls), than cast c as Textbox. ...
                    	}
                    
                                //button click
                    	private void button2\_Click(object sender, System.EventArgs e)
                    	{
                    		OpenFileDialog dlg = new OpenFileDialog();
                                        dlg.Multiline = true;
                    		if (dlg.ShowDialog() == DialogResult.OK)
                    		{
                    			for(int x=0;x
                    

                    If I didn't understand you right, please let me know.

                    All the best,

                    Martin

                    -- modified at 5:39 Thursday 1st February, 2007

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups