Hello everyone,
I have a program called Analyze.exe. It is normally ran from the command line like this:
c:\analyze.exe "C:\some path\filename.dat" "C:\some path\filename.out"
I want to run this program from some C# code, but it is failing. It appears to be failing because there are spaces in the filename being passed in. If anyone knows what I am doing wrong or has another idea how to accomplish this please point it out!
public void runProcess()
{
string inputPath = "\"C:\\some path\\filename.dat\"";
string outPutPath = "\"C:\\some path\\filename.out\"";
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = "c:\\analyze.exe"
pProcess.StartInfo.Arguments = inputPath + " " + outputPath;
pProcess.Start();
pProcess.WaitForExit();
pProcess.Close();
}
After the execution of the 5th line inside the method body --
If you were to poll the pProcess.StartInfo.Arguments property value, you see what you would expect. ( a string with Quote marks at the begining and ending of the string. )
Somewhere in the execution of the above code the Quote marks are being omitted from the Arguments causing problems down stream!
To test this I replaced the actual Analyze.exe with this program listed below.
class Program
{
static void Main( string[] args )
{
for ( int i = 0; i < args.Length; i++ )
{
Console.WriteLine("args[i] = " + args[i] );
}
Console.ReadLine();
}
Any help will be deeply appreciated,
Mike