WikiFunctions.Tools.OpenURLInBrowser C# (CSharp) Method

OpenURLInBrowser() public static method

Error supressed URL opener in default browser (Windows) or Firefox/Chromium/Konqueror for Wine
public static OpenURLInBrowser ( string url ) : void
url string
return void
        public static void OpenURLInBrowser(string url)
        {
            // For Wine use attempt to dynamically determine available browser, caching result
            if (WineBrowserPath == null)
            {
                if (File.Exists("/usr/bin/firefox"))
                    WineBrowserPath = "/usr/bin/firefox";
                else if (File.Exists("/usr/bin/chromium-browser"))
                    WineBrowserPath = "/usr/bin/chromium-browser";
                else if (File.Exists("/usr/bin/konqueror"))
                    WineBrowserPath = "/usr/bin/konqueror";
                else WineBrowserPath = ""; // Windows, or Wine and none of these browsers available
            }
            try
            {
                if (!Globals.UnitTestMode)
                {
                    if (WineBrowserPath.Length > 0) // Wine
                        System.Diagnostics.Process.Start(WineBrowserPath, url);
                    else // Windows
                        System.Diagnostics.Process.Start(url);
                }
            }
            catch { }
        }

Usage Example

        public void OpenPageHistoryInBrowser(string title)
        {
            if (!Variables.UsingSecure)
            {
                string url = ArticleUrl.Replace("$1", title);

                Tools.OpenURLInBrowser(url + "?action=history");
            }
            else
            {
                Tools.OpenArticleHistoryInBrowser(title);
            }
        }
All Usage Examples Of WikiFunctions.Tools::OpenURLInBrowser
Tools