I recently had this idea to create a C# Windows Form App that enables a user to launch applications from there. This is my ‘raw’ code:
Button1 Click Event…
{
System.Diagnostics.Process.Start("WINWORD.EXE");
}
Button2 Click Event…
{
System.Diagnostics.Process.Start("WINRAR.EXE");
}
.
.
.
.
.
.
and many more …
Can anyone please tell me what the code is in case that handles the event in case that an application cannot be found(ex. WINWORD.EXE is not available blah, blah blah)?
I tried using the ‘if-statement’ but to no avail, I get compilation errors.
Can someone help me out? How can I create a function that lets the user add some application shortcut to the C# app?
Thanks to everyone in advance.
I would just put your call to launch the app into a
try...catch...blockButton2 Click Event…
In this case, no matter what goes wrong, you’ll be able to catch that case and at least show a message to the user – of course, you might want to “tweak” that message a bit …..