I'm trying to open a document in either of two files using the below code:
try
{
startInfo.FileName = "WINWORD.EXE";
}
catch(Win32Exception)
{
startInfo.FileName = "TMViewer.exe";
}
I don't have MS Word on my laptop so I was hoping the catch would trigger it to open in a Word viewer program but I get that message:
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
I've upadating the registry to pick up the shortcut of running TMViewer.exe
and it actually works on my other PC but if I try to run it on my laptop that doesn't have Word installed I keep getting this error.
The exception is thrown when you Start()
the process, not when you set that option.
However, you don't need to do any of that.
Instead, just set FileName
to the document you're trying to open, and Windows will automatically open it in the user's associated program.