Added automatic directory creation in case a directory tree does not exist