Use try/catch instead of filesystem check.  This works well and is much more readable.