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
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 to share