2

I have created my program in the compact framework 3.5, and I am trying to open an html file in my program using this code:

string path = @"Help\index.html";
System.Diagnostics.Process.Start(path);

However I am receiving the following error:

Argument '1': cannot convert from 'string' to 'System.Diagnostics.ProcessStartInfo'

Can someone please tell me what I am doing wrong?

nate
  • 1,418
  • 5
  • 34
  • 73

2 Answers2

3

Your code is working for me; however, you can try the following code:

System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(path); 
System.Diagnostics.Process.Start(p);

Alternatively, you can try:

Process.Start("chrome.exe", path);
Muhammad Imran
  • 734
  • 7
  • 21
2

This worked better for the Compacted Framework 3.5 for Windows Embedded 6.5. I wouldn't have gotten this without Muhammad imran answer.

Here is the code:

Process myProcess = new Process();

            try
            {
                // true is the default, but it is important not to set it to false
                myProcess.StartInfo.UseShellExecute = true;
                myProcess.StartInfo.FileName = "http://some.domain.tld/bla";
                myProcess.Start();
            }
            catch (Exception er)
            {
                Console.WriteLine(er.Message);
            }
        }
nate
  • 1,418
  • 5
  • 34
  • 73
  • You need to set useShellExecute to true because you aren't launching an executable directly (that would happen only if you pass a ".exe" file as filename and so the system need to discover which application is connected to the resource you want to start. This is done by searching into the registry and it's what explorer (the shell) does usually. – Valter Minute Jul 10 '15 at 06:34