Directory creation error

I have two commits in this pull request because GitHub was being stupid and wouldn't let me make a pull request with my other branch.

This should fix issue #3985.  I have checked it out on the Linux build so I am not a hundred percent sure but it appears to work just fine.