Can I verify a file exists before I LoadImage()?

BlitzMax Forums/BlitzMax Beginners Area/Can I verify a file exists before I LoadImage()?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

My game has a different background image for each stage. So far, this is the simplest way I can think of to load it:

BackgroundImage = LoadImage("graphics\stage"+Level+".png") 


It works very nicely, as long as the image it's searching for exists. I don't like the way it fails, though, if the file doesn't exist. (Unhandled Memory Exception Error. Ewwww!)

Is there any way I can check to ensure the png file exists before I try to load it? Perhaps using stage1.png as a handy default image, if the correct png file can not be found? It's not like I plan on releasing the game without as many images as there are stages... I'd just really feel a LOT more comfortable with a default image behavior, as opposed to an abrupt crash.