Load a picture file and check for existence

Hey all,

I need some help with a feature in my project. Using Xojo current version, Windows 8.1.

I wish to load a picture file based on a variable name (the name of a person in my project). For example, when a window loads, if the variable is “Jeff Smith”, I want it to check the current running folder for a file named “Jeff Smith.jpg” and load it into a Canvas…if that file exists. I want it to just move on by itself and continue execution if the file does not exist.

How would I do this in code? Thanks for any help!

dim name as string = "Jeff Smith"
dim f as folderitem = GetFolderItem(name + ".jpg")
if f.Exists then
   dim p as picture = picture.Open(f)
   canvas1.backdrop = p