I have a saved url in a database linked to a windows form. How do I take the url and open a web broswer?
this is where its stored
m_dtMedia.Rows[m_rowPosition]["File_Path"]
what I want is when you click a button for the web broswer to oepn up.
I have a saved url in a database linked to a windows form. How do I take the url and open a web broswer?
this is where its stored
m_dtMedia.Rows[m_rowPosition]["File_Path"]
what I want is when you click a button for the web broswer to oepn up.
private static void OpenBrowser(string url)
{
if (url != null)
{
Process process = new Process();
process.StartInfo.FileName = "rundll32.exe";
process.StartInfo.Arguments = "url.dll,FileProtocolHandler " + url;
process.StartInfo.UseShellExecute = true;
process.Start();
}
}
Since spawning another process takes a bit of time, while that is occuring your UI will be blocked. I recommend calling this method from a background thread. For example:
Task.Factory.StartNew(()=>{OpenBrowser(url);});
This method is used because calling Process.Start(string) from a UI thread causes an exception
You can just start a new process with the url as the target/filename:
Process.Start("http://www.google.com");
This will have the effect of using the default browser to load the url.