0

I have the absolute path of internet explorer executable and the absolute path of an xml file, and i want to open that xml using IE. The code i wrote works fine if there aren't any instance of IE already opened. If there is an IE instance opened, IE will be launched and will convert the filesystem path in something like an URL.

First instance of IE open this path: (and works fine) C:\workingfolder\preparazioni\DichiarativiDP\RESPONSABILE CONSERVAZIONE\IPdV.xml

Next instance of IE open this path: (and fails)

http://%22c/workingfolder/preparazioni/DichiarativiDP/RESPONSABILE%20CONSERVAZIONE/IPdV.xml%22

This is my code:

 Process proc = new Process();
            proc.StartInfo.UseShellExecute = true;

            //IE executable absolute path
            proc.StartInfo.FileName = sApplication;
            //Xml file absolute path
            proc.StartInfo.Arguments = "\"" + file + "\" " + sAdditionalArguments;

            proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;     
            proc.Start();

I tried the same code calling Chrome browser and it works fine, opening a new tab every time.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nicola
  • 1
  • 1
  • I have tried your code with ie 10.0.9200.16660 and it works fine. If ie is not running it will open ie and display the xml file and if ie is running it will open a new ie window and will dispaly the xml file too. Cannot reproduce your error. Which version do you use? – syatrix Sep 04 '13 at 14:53
  • Hi, thanks for trying it. Im using the same version of IE. After spending hours on it, i've just found the solution. I omitted a space in the code, and that space was the problem. In fact, i wrote this code line: proc.StartInfo.Arguments = "\"" + file + "\""; where it actually was: proc.StartInfo.Arguments = "\"" + file + "\" " + sAdditionalArguments; Since i have sAdditionalArguments usually empty, in StartInfo.Arguments i had an ending space, which caused my problem. I still don't know why the problem doesn't trigger at the first call. – Nicola Sep 04 '13 at 15:04
  • When IE is already running on the system, invocation of a new instance ends of communicating with the old instance. It sounds like you've found an edge case in that communication. – EricLaw Sep 04 '13 at 15:56

0 Answers0