Edit: I didn't mean to pinhole this question to a specific executable. I want this to work for any executable. If I was to type in the FileName into a run dialog, and the result is the "Windows cannot find ..." dialog, then I dont want to Start that process. Updated below...
I would like to execute 'an executable' in my program, but if the user doesn't have the executable installed, I want to run another process. How can I check BEFORE actually starting the visio process that visio is installed on the system? I do not want a popup "Windows cannot find "executable"...
Here's my code. But this does give the "Windows cannot find "executable".." error pop-up.
System.Diagnostics.Process myProc = new System.Diagnostics.Process();
myProc.StartInfo.FileName = "an executable.exe";
myProc.StartInfo.Arguments = "MyDoc.txt";
myProc.StartInfo.WorkingDirectory = "C:\MyFolder";
try
{
if( !myProc.Start() )
{
myProc.StartInfo.FileName = "another process.exe";
myProc.Start();
}
}
catch (Exception ex)
{
...
}