Use isDirectory to determine if the file is a directory