views:

255

answers:

1

Just wondering if there is another way to handle this as the arguments are getting split when passing in like this:

System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(fileName);
psi.Arguments = @"c:\dir1\dir2\dir3\file1.txt";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = psi;
p.Start();

Then, in the new application when we access Environment.GetCommandLinesARgs() We are getting an array that looks like this:

string[] arr = {"filename","c:\dir1","dir2","dir3", "file1.txt"}
+2  A: 

The problem is that you aren't passing the arguments in correctly.

You need to include quotes around the path, like this:

psi.Arguments = @"""c:\dir1\dir2\dir3\file1.txt""";
Simon P Stevens
This is only necessary if there are spaces in the path -- not the case in the posted code, though quite possibly the case in the real code!
itowlson