开发者

Open Default browser with Mono+gtk#

I need t开发者_如何学Goo open an url from my application, on both linux and windows and i want to avoid replacing an existing page on an open browser.

How do i call for it to open?

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 on an already open browser window.

i found this article ( thx 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.


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 for all linux desktops. Like grombeestje said, you should probably implement it separately for Windows and linux.


i would suggest to check on what OS the app is running, and then implement it for each OS separately.


After searching through the Banshee source code I see that they use Gnome.Url.Show() (In gnome-sharp) to open the users default browser.

If that isn't possible for whatever reason, a couple of other ideas come to mind.

If the user is running Gnome there should 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 sensible-browser.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜