Make sure the relevant directories are created before trying to use them.