in reply to Checking for valid directory
What exactly isn't working? I tried this with a good directory and a non-existent directory and it worked correctly in detecting the existence of the directory. Couldn't tell you whether or not it is a problem in your sub, because there is no code provided.
Are you sure that you have permission to read the directory. Maybe you should check that as well.