Open default browser with Mono + gtk #

I need to open a URL from my application, both in Linux and Windows, and I want to avoid replacing the existing page in an open browser.

How can I open it?

I know I can use

System.Diagnostics.Process.Start("http://mysite.com");

      

which should also work under Linux, but this will replace any page shown in an already open browser window.

I found this article (thanks to Nissan Fan ):

System.Diagnostics.Process.Start (" http://mysite.com ");

but this only works for windows and I need a solution that will work on both systems.

+2


source to share


3 answers


I think this is what you want:

System.Diagnostics.Process.Start ("xdg-open http://mysite.com");

      



This will only work on Linux, but should work on all Linux servers. Like grombeestje, you should probably implement it separately for Windows and Linux.

+3


source


I would suggest checking which OS the application is running on and then implementing it for each OS separately.



0


source


After searching through the Banshee source code, I see that they are using Gnome.Url.Show()

(In gnome-sharp) to open the default browser for users.

If this is not possible for some reason, a couple of other ideas come to mind.

If the user runs Gnome, there must be a program called "gnome-open" that should do the trick.

System.Diagnostics.Process.Start("gnome-open http://mysite.com");

      

And if that doesn't work, I know that (at least) all Debian based systems come with a script called sane browser.

System.Diagnostics.Process.Start("sensible-browser http://mysite.com");

      

0


source







All Articles