C # 4.0: Is there a way to check if an application is not in System.Diagnostics.Process.Start

I want to open any type of file using the following code:

System.Diagnostics.Process.Start(pathFile);

      

Is there a way to check if a system app doesn't exist?

eg: pdf, local machine does not have acrobat reader.

I created a catch attempt but I am not satisfied with it, I want to emulate the behavior of windows when opening a file. It has web search / manual search capability.

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

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

      

+2


a source to share


2 answers


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



+2


a source


If there is no association, he must throw away Win32Exception

, which you could catch.



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

0


a source







All Articles