I am trying to use a string containing XML as an argument when calling Process.Start, however only characters up to the first space get through. For example if Input.xml contained the following text <?xml version="1.0" encoding="utf-8" ?> all the application I’m calling receives is "<?xml".
Here’s the sample of the code to put this into context:
XmlDocument xml = new XmlDocument();
xml.Load("C:/Input.xml");
Process proc = Process.Start("C:/Program.exe", xml.OuterXml);
Is there any way around this?
Trying to pass the XML data as a command line argument is basically a recipe for problems. You’ll run into escaping problems all over the place, and probably command line length limits too.
Either read from standard input or a filename. At that point, it’s pretty easy – a file is generally simpler than providing data to stdin, but both are feasible.