views:

58

answers:

2

I want to open any file type by using the code below:

System.Diagnostics.Process.Start(pathFile);

Is there a way to check if system application not exist?

for example: pdf, the local machine has no acrobat reader.

I created a try catch, however I'm not satisfied with it, I want to imitate the behavior of windows in opening a file. It has an option of Searching the web / manual search.

try
            {
                System.Diagnostics.Process.Start(pathFile);
            }
            catch (System.ComponentModel.Win32Exception ex)
            {

                composite.ReadingError = ex.Message;
                Console.WriteLine("error");
            }
A: 

If there is no association it should throw a Win32Exception that you could catch.

See here: http://msdn.microsoft.com/en-us/library/53ezey2s.aspx in the exceptions section.

Nathan
I tried it; it doesn't.
SLaks
A: 

You need to use PInvoke (FindExecutable (shell32)):

Mitch Wheat