File read and write worked from godot console but not work on exported app

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hossein Vatani

Hi every one,
I made my first game and wrote the below functions to read and write the game date

func fDict2JsonFile(dictIn:Dictionary,fileName:String=gMainFileName)->bool:
var file =
	print("Error opening file")
	return false
return true

func fReadJson2Dict(matchName:String="",seekNo:int=-1,fileName:String=gMainFileName)->Dictionary:
var file =
if !file.file_exists(fileName) ||, File.READ) != 0:
	return {}
if matchName.empty():
	return parse_json(file.get_line())
if seekNo!=-1:
	var line=parse_json(file.get_line())
	if fFileLineCheck(line,matchName,file): return line
	while file.get_position() < file.get_len():
		var line=parse_json(file.get_line())
		if fFileLineCheck(line,matchName,file): return line
return {}

read and write work correct when I’m in Godot, I mean when in programming and use F5 key…
but when I export a game, read and write not work in Linux, Android, and Windows platforms.
shall I consider any extra issue to serve this? is it a bug?
many thanks

:bust_in_silhouette: Reply From: AlexTheRegent

When you building your game, you need to add custom files to export. This is done in Project → Export → Select preset you want to export → Open Resources tab and add *.json (if your configs have .json extension) to filters to export non-resource files/folders.

thanks,I use this user://gamedata.db, is it should be known file type?

Hossein Vatani | 2021-01-07 13:52

Export only affects files in res:// folders. So it is not the case. Then, instead of if,File.WRITE)!=0: try to save error code and print it to see what’s wrong.

error =,File.WRITE)
if error!=0:
    print("Failed to open file, error code: %d" % error)

Descriptions of error codes can be found here @GlobalScope — Godot Engine (stable) documentation in English

AlexTheRegent | 2021-01-09 14:55