tags:

views:

114

answers:

2

I am trying to find something in the gnome libs to do this:

Gnome.GnomeOpen(url_string);

and gnome will open the URL with the preferred gnome application

Does this exist?

+1  A: 

Untested:

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false; 
proc.StartInfo.FileName = "xdg-open"; //best guess
proc.StartInfo.Arguments = string_url;
proc.Start();
proc.WaitForExit();

I don't have linux here at work to test this, but you should be able to accomplish what you want by changing the command to what it needs to be, using the above as a template.

Chris McCall
This will work on a recent Linux, but it's not portable. However, as jpobst said, Process.Start can open HTTP URLs (and most files) directly, using the appropriate handler on Mac/Windows/Linux - which in the case of Linux would indeed be xdg-open. You can disable this behaviour by setting proc.StartInfo.UseShellExecute = false.
mhutch
+1 thanks for the additional info
Chris McCall
+2  A: 

Process.Start should handle all the messy work for you:

Process.Start ("http://www.mono-project.com");
jpobst