Q:

c# - How to open a html file in a web browser that is not the default one?

I am trying to open a html file in a web browser that is not the default one. Up to now, I am able to open an html file in the default web browser with :
System.Diagnostics.Process.Start("  File location  ");
But is there a way to open the file in a web browser that is not the default?
It would be great if i can obtain a webBrowser object by the process. I already find how to determine if my desired web browser is opened with:
var runningProcess = System.Diagnostics.Process.GetProcessesByName("chrome");
if (runningProcess.Length != 0)
{
}
Also I can't change the default web browser, I will use the application on school computer's.
Thanks

A:

You can use below code:
Online page :
System.Diagnostics.Process.Start("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "http://wwww.testdomain.com/mypage.html");

Offline Page:
System.Diagnostics.Process.Start("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "C:\Users\AppData\Local\Temp\mypage.html");

A:

If you want to open a website in chrome from c#, try:
System.Diagnostics.Process.Start("chrome", "www.google.com");

Using your code, I think you're trying to get any open browser first?
var runningProcess = System.Diagnostics.Process.GetProcessesByName("chrome");
if (runningProcess.Length != 0)
{
    System.Diagnostics.Process.Start("chrome", filename);
}
runningProcess = System.Diagnostics.Process.GetProcessesByName("firefox");
if (runningProcess.Length != 0)
{
    System.Diagnostics.Process.Start("firefox", filename);
}
runningProcess = System.Diagnostics.Process.GetProcessesByName("iexplore");
if (runningProcess.Length != 0)
{
    System.Diagnostics.Process.Start("iexplore", filename);
}

