+5 votes

This works inside the godot engine but not when I export the game.
the game has chmod 777

Writing a File works but creating a folder doesn't


var d = Directory.new()
if( !d.dir_exists(path) ):
    var err = d.make_dir_recursive(path)


ERROR: make_dir_recursive: Method/Function Failed, returning: err At: core/os/dir_access.cpp:186.

Creating a folder with make_dir(path) also doesn't work.

in Engine by (175 points)
edited by

2 Answers

+3 votes
Best answer

I was having this same issue until I had an aha moment.
directory (or d in this case) needs to open the path you want to make the directory at
you should set the path variable to a directory that exists already and you will be making the new directory in that existing directory.

the reason on a exported game why this does not work is because d's current directory is "res://" which is inside of your executable and not accesible

i hope this helped a bit.

by (55 points)
selected by

Is function worth remembering

+2 votes

it should look like this:

var d = Directory.new()
if !(d.dir_exists("user://somedir")):
    print("ERR: dir does not exist ")
by (196 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.