fix Dir throwing a System Exception not an InvalidArgumentException