Can't figure out the last requirement. Is it possible that it would be cause by empty directory? Is it related to the PathNotFoundException?