I'm just finishing off coding a a document storage solution and I've run across the following issue. Within the UI the user can press a button to open a file:
try
{
Process.Start(file);
}
catch (Exception ex)
{
//Error handling code
}
My issue is that if the user has no application associated with the file type a componentmodel exception is thrown with a message to that effect.
What I'd rather do is have the "Open with" dialog pop-up in that situation, is there a method call I'm missing?
You can check the registry to see if you have an application associated with that file type before calling Process.Start. Alternatively, you can catch the componentmodel exception and open the open with dialog from there.
See this article for using the Open With dialog
http://www.codeproject.com/KB/shell/openwith.aspx
I would put the Process.Start call in a try statement, and then show the "Open With" in the catch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With