Added additional validation for target directories.

- Added validation for target directories. An error will be thrown if
the directory is a file rather than a folder.