Error handler (Process.Start)

Blayer98

Active Member
Hi guys!

I'm making a Launcher in Visual Studio Express, and I'm trying to make an error handler for if the exe file specified in "Process.Start()" doesn't exist.

I'm trying to get a msgbox appear, but I'm not sure how to get it appear if the file doesn't exist. Any help is appreciated! :3
 
File.Exists method to check before you run Process.Start (if statement)
http://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx

Or you can catch the exception it throws. The documentation tells you what exceptions are thrown: http://msdn.microsoft.com/en-us/library/53ezey2s(v=vs.110).aspx, see it says "FileNotFoundException"

try {
Process.Start...
}catch(FileNotFoundException ex){
//Do something
}

I get this error: System.ComponentModel.Win32Exception.
By the way, the code for the button I'm setting it to is in .vb.

EDIT: It works now! :D
index.php
 
Last edited:
Back
Top