i am making and app to open patch then save a file also it has an iso compressor external program that i would like to use.
everything works fine until i have a space in the filename or folder path
ie
when passing the parametrs to the exe in a cmd window
you would type say
test -a -b input.iso output.iso
my code is
ProcessStartInfo startInfo = new ProcessStartInfo("C:/whatever.exe");
startInfo.Arguments =
"-w -l " + textBox2.Text + " " + textBox3.Text; Process.Start(startInfo);textbox2 is the input file textbox3 is the output file
everything works fine if the text box values are say c:\test\test.iso
but not if textbox text is say c:\test folder\test.iso
i can save to say c:\test 1.iso but not open c:\test 1.iso
i am sure its just me as i never used C# before
any help would be great
regards
justin

probs with space in textbox ?
Keith Walton
that worked great but what if i want -l to have a value from a combo box
say -l has 9 values in a combo box
ie
startInfo.Arguments = String.Format("-w -l9 \"{0}\" \"{1}\"", textBox2.Text, textBox3.Text);
wants to have the 9 selected from the combo box
startInfo.Arguments =
String.Format("-w -l \"{0}\" \"{1}\"", comboBox1.Text, textBox2.Text, textBox3.Text);there can not be a space between the l & 9 but must be 1 after it
thanks
judir
Try surrounding your arguments in double quotes:
startInfo.Arguments = String.Format ("-w -l \"{0}\" \"{1}\"", textBox2.Text, textBox3.Text);
Hope this helps
--mc
Dudday
thank you all for your help works great and i know undertand how it works
thanks again
chossy
Andres C. Joaquin
Then you would modify the String.Format command to be the following:
startInfo.Arguments = String.Format("-w –l{0} \"{1}\" \"{2}\"", comboBox1.Text, textBox2.Text, textBox3.Text);
The {n} construct is a placeholder in the string for the values found in the rest of the parameters in the method call.
Hope that helps.