Written .txt file not appearing in folder on export

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mextie-dev

I am newish to Godot, and have checked just about everything I can find on this issue, with no luck. I am trying to make a system where when the player does something, a text file appears in the folder that the game is being run from. My code for this is like so:

var __my_file := File.new()
var __my_text := str("test_text")

Then, I call this when I save to the .txt file.

	__my_file.open("res://Test.txt", __my_file.WRITE)
	assert(__my_file.is_open())
	__my_file.store_string(__my_text)
	__my_file.close()

When running the game from the editor, this works totally fine. The text file shows up in the main res:// folder. However, when I export the game, the .txt file doesn’t show up in the folder the .app is running from, nor any of the surrounding folders. I am using the default MacOS export settings, with *.txt in the force export line, to no avail. I cannot figure out how to do this.

:bust_in_silhouette: Reply From: whiteshampoo

You cannot write to res:// after exporting.
Instead you can write to user://

On windows you can find this somewhere in
%appdata%/Godot\app_userdata/project_name

Under Linux i think it is in
~/.local/share/godot/app_userdata/project_name
(unsure)

More info about this: Link