Calling external application with arbitary input parameters
-
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!
-
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!
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
-
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!
-
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!
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
-
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
-
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
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.
-
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.
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
-
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
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
-
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
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