how to check whether the specific path is a file or a folder?