+1 vote

As the title say, I can not load cfg file via ConfigFile class. Everything works fine on Windows, but when I export game for Android it throws an ERRCANTOPEN error. I tried to load this file via File class and it doesn't work too, but this time error code equaled 3, ERR_UNCONFIGURED.

Sorry for any language mistakes, but I'm not native.

in Engine by (151 points)

Is it a custom config file in your project folder? If so, export with the "Export all files" option, or make sure to whitelist this file (or all *.cfg files), otherwise it might not be exported (and thus it runs fine in the editor which uses the normal project folder, but not with the exported data pack).

Thanks, that was it :)

Great, I'll turn my comment into an answer then.

2 Answers

+2 votes
Best answer

When you export your game, you have several possibilities to define what files should be exported.

By default, only resources (i.e. files that Godot knows are necessary since they are loaded by scenes) are exported, which means that if you load a text or config file from code, it won't be exported.

You can fix that by selecting the "Export all files" option, or by whitelisting the specific files or file types you want to include in the data pack.

by (1,958 points)
selected by
+1 vote

380/5000
I faced this problem too, so I stuck a lot until I did the following.
1- Change file directory to user: //
2-Copy and paste your cfg file where is your project in "user", how to find? just go to C: \ Users \ Lara \ AppData \ Roaming \ Godot \ app_userdata \ ProjectName
3-Go to on Export >>> Resource >>> Filters to export non-resource files: type * .cfg
Ready :3

by (46 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.