Advertisement

07.09.2008 at 10:23AM PDT, ID: 23551072
[x]
Attachment Details

Path name not correct

Asked by LuckyLucks in .NET, C# Programming Language

Hi I needed to make a reference to a path as below. But it seems the space in Program Files trips it. How do I fix this? Note there is no issues when the foldernames are without spaces like in my second example.

not working:
string command = String.Format (@"C:\Program Files\IBM\SQLLIB\myfile.bat {0} {1}", "testparam1", "testparam2");

woking:
string command = String.Format (@"C:\MyDocuments\Assignments\AdHoc\myfile.bat {0} {1}", "testparam1", "testparam2");

Full code:

System.Diagnostics.Process ps = new System.Diagnostics.Process ();
System.Diagnostics.ProcessStartInfo psinfo = new System.Diagnostics.ProcessStartInfo ();
psinfo.FileName =@"C:\Program Files\IBM\SQLLIB\BIN\db2cmd.exe";
string command = String.Format (@"C:\Program Files\IBM\SQLLIB\myfile.bat {0} {1}", "testparam1", "testparam2");
psinfo.Arguments = "/W " + command;
psinfo.UseShellExecute = false;
psinfo.CreateNoWindow = true; // try both true or false
psinfo.RedirectStandardOutput = true;
psinfo.RedirectStandardOutput = true;

ps.StartInfo =psinfo;
bool val = ps.Start ();
ps.WaitForExit ();

int exitcode = ps.ExitCode;
ps.Close ();

Start Free Trial
 
 
[+][-]07.09.2008 at 11:27AM PDT, ID: 21966730

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 11:27AM PDT, ID: 21966739

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, C# Programming Language
Sign Up Now!
Solution Provided By: Babycorn-Starfish
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.09.2008 at 01:03PM PDT, ID: 21967730

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 07:58PM PDT, ID: 21970159

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628