I have a URL and I want to launch it in the default browser. I've tried two methods:
Process.Start("http://stackoverflow.com");
... and the one detailed in this other question using ShellExecute.
In both cases I get the error: Windows cannot find 'http://stackoverflow.com'. Make sure you typed the name correctly, and then try again.
It shouldn't be trying to open it as a file though... from what I understand, it should recognize it as a URL and open it in the default browser. What am I missing?
By the way: OS = Vista, and .NET = 3.5
EDIT:
According to this MS KB article, since Process.Start sets the UseShellExecute by default, it should launch the default browser.
EDIT:
Here's what does work:
System.Diagnostics.Process.Start(@"C:\Program Files\Internet Explorer\IExplore.exe", "http://stackoverflow.com");
Unfortunately that really doesn't launch the default browser, and it also doesn't work if IE isn't installed in the "normal" place. I'm not sure what to do here.
More information:
OK, so the error I'm getting is error number -2147467259. Looking at Google for this, it appears that it's not very descriptive. It might be a file association error or something.
The plot thickens:
So I checked the registry key that's supposed to have my file association for http:
KEY_CLASSES_ROOT\http\shell\open\command\default
Here's the value:
"C:\Program Files\Mozilla Firefox\firefox.exe" -requestPending -osint -url "%1"
That makes sense. I actually copied this string into a command prompt and replaced the %1 with http://stackoverflow.com and it worked and opened firefox. I just don't get why Process.Start isn't associating the URL with this command...