File path problem (Path contains a space)
-
Hi, I am trying to start an application from my application, which opens a default file, given it's arguments as follow:
Process prc = new Process();
prc.StartInfo.FileName = "azman.msc";
prc.StartInfo.Arguments = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml"; // CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin
prc.Start();Note the current curectory is: CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin Which contains spaces. For some or other odd reason, it does not like this ... If this directory is in such a location that there are no spaces in the Directory name, then this works fine... Can I replace the spaces of the directory with something ? How can I fix this problem. Any help would be much appreciated!
-
Hi, I am trying to start an application from my application, which opens a default file, given it's arguments as follow:
Process prc = new Process();
prc.StartInfo.FileName = "azman.msc";
prc.StartInfo.Arguments = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml"; // CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin
prc.Start();Note the current curectory is: CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin Which contains spaces. For some or other odd reason, it does not like this ... If this directory is in such a location that there are no spaces in the Directory name, then this works fine... Can I replace the spaces of the directory with something ? How can I fix this problem. Any help would be much appreciated!
It's not odd, the space is used as a delimiter for arguments. Put the path in quotes to get around this.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
It's not odd, the space is used as a delimiter for arguments. Put the path in quotes to get around this.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
LOL .... thanks ^_^ prc.StartInfo.Arguments = "msxml://" + "\"" + Environment.CurrentDirectory + "\\AuthorizationStore.xml" + "\""; Is this the way to escape a " character?
-
LOL .... thanks ^_^ prc.StartInfo.Arguments = "msxml://" + "\"" + Environment.CurrentDirectory + "\\AuthorizationStore.xml" + "\""; Is this the way to escape a " character?
Yes. I believe that single quotes work as well, but that's how you escape double ones.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )