Quick answer: The file is not in the PCK, or not under the name you open. Add non-resource files (*.txt, *.cfg, *.csv) to Export > Resources > Filters to export non-resource files/folders; set CSVs that are data (not translations) to Keep File in the Import dock; match file name case exactly; and remember DirAccess lists .import and .remap names in exports.

Everything loads in the editor, the export starts fine, and then your level data, dialogue file or config comes back null. The editor reads your project folder directly; the exported game reads a PCK that only contains what the exporter decided to include, under the names it gave them.

Step 1: see the real error

var f := FileAccess.open("res://data/levels.txt", FileAccess.READ)
if f == null:
    push_error("Open failed: %s" % error_string(FileAccess.get_open_error()))

“File not found” in the export but not in the editor means one of the causes below. Run the export with a console (or check the log in user://logs) to see the message.

Cause 1: the exporter skipped non-resource files

Godot exports resources it recognizes: scenes, scripts, textures, audio, and other imported or resource types. Arbitrary files such as .txt, .cfg, .ini, .md, .yaml or .bin are not resources, so they are left out unless you ask for them.

Open Project > Export, select the preset, go to the Resources tab and add patterns to Filters to export non-resource files/folders:

*.txt, *.cfg, data/*

Each export preset has its own filters, so set them for Windows, Linux, macOS, Android and Web.

Cause 2: “Export selected scenes” mode

If the preset's Export Mode is Export selected scenes (and dependencies), only files those scenes reference are included. A file you open by path string inside a script is not a dependency the exporter can see, so it is dropped even if it is a recognized resource type such as JSON. Either switch to Export all resources in the project, or add the folder to the filters above.

Cause 3: CSV files were imported as translations

Godot imports .csv files as translation tables by default. The export then contains .translation files instead of your CSV, and reading the CSV with FileAccess fails. For CSVs that are game data, select the file, and in the Import dock change Import As to keep the file as is, then click Reimport. Recent 4.x versions label the option Keep File (exported as is).

Cause 4: the file name case does not match

Windows and default macOS file systems are case-insensitive, so res://Data/Levels.txt opens data/levels.txt in the editor. The PCK is case-sensitive, and so are Linux, Android and the web. Match the case in your code to the case on disk exactly, and prefer all-lowercase file names to avoid the problem entirely.

Cause 5: DirAccess lists different names in exports

If you discover files by listing a folder, an export behaves differently: imported files appear as name.png.import and converted resources as name.tscn.remap, because the originals are not in the PCK. Strip those suffixes before loading:

func list_resources(path: String) -> PackedStringArray:
    var out := PackedStringArray()
    for file in DirAccess.get_files_at(path):
        file = file.trim_suffix(".import").trim_suffix(".remap")
        if not out.has(file):
            out.append(file)
    return out

Godot 4.4 and later also offer ResourceLoader.list_directory(), which returns the loadable names in both the editor and exports.

Writing files: use user://, never res://

res:// is read-only in an exported game. Saves, settings and logs go in user://, which maps to a per-user folder on each platform. Code that writes to res:// works in the editor and fails silently after export.

Files missing on players’ machines

Missing-file errors in an export are logged as errors on the player's machine, then usually followed by something worse. Bugnet's Godot SDK is a single GDScript autoload that watches the engine log and files errors, script errors and fatal errors automatically with recent log lines, a screenshot, the platform, OS, hardware and game version, and players can report everything else through Bugnet.show_widget().

Frequently asked questions

Why does FileAccess.open return null in my exported Godot game?

The file was not exported, or it was exported under a different name or case. Add non-resource files to the export filters, keep data CSVs as files, and match the file name case exactly.

How do I include .txt or .cfg files in a Godot export?

In Project, Export, select the preset, open the Resources tab and add patterns such as *.txt, *.cfg to Filters to export non-resource files/folders.

Why does DirAccess list .import and .remap files in my export?

Exports replace original files with imported or converted versions. Strip the .import and .remap suffixes, or use ResourceLoader.list_directory() in Godot 4.4 and later.

The editor reads your folder. The export reads a PCK. Test the export, not the editor.