What should be a tricky question has now consumed an hour of my time! > __ <
I want to run an executable using the xml path as an argument. (I added the directory in which this program is on my system path.) It seems pretty simple. My first approach was to use the static Process.Start () method as such:
Process.Start(@"MyExecutable.exe", "C:\\My Doc\\SomeDirectory\\MyXMLPath.xml");
The process begins, but after half a second he dies. So, I look like ooookaay, maybe the executable doesn't like the argument I give it? For a giggle, I created a shortcut for the executable and added the path to the xml file as one of its arguments. The program starts and starts as expected. Not sure why this works, I decided to check my luck on the command line too:
C:\MyExecutable.exe "C:\My Docs\SomeDirectory\MyXMLPath.xml"
No problem with this path.
Now, at that moment, I started grabbing at a straw and decided to create an instance of the Process class:
Process proc = new Process ();
proc.StartInfo.FileName = @ "MyExecutable.exe";
proc.StartInfo.Arguments = "C: \\ My Docs \\ SomeDirectory \\ MyXMLPath.xml";
proc.Start ();
Needless to say, this did not help at all ..> & L;
So exhausted, I decided to test my luck by commenting on one line:
//proc.StartInfo.Arguments = "C:\\My Docs\\SomeDirectory\\MyXMLPath.xml";
And the process begins. Not with his necessary arguments, but he begins. So, the question is why the program does not accept the path that I give it when I try to run it through the Process class? If he had left me a message when the program died. :(
Any thoughts? Very grateful!