Load All .txt Files From Directory

The solution to this seemingly simple problem has eluded me. Quite simply, every solution I’ve come across fails to implement properly due to errors during compilation or simply adds the file to the root directory of the game with my attempted sub-folder being added to the filename instead.

ie “HelloWorld.txt” saved to FPaths::GameDir() + TEXT("\Saved\Prompts")

^NOTE: \ not \ because \ = escape character and causes compilation failure.

Results in a text file named SavedPromptsHelloWorld.txt inside of my game’s root directory.

Additionally when I build out the game for Windows 64 Bit Shipping (only one I’ve tried) that doesn’t work at all. No files are created or loaded anywhere as far as I can tell.

So I’m looking to specifically save and load files to C:\MyGame\Prompts

And when loading them the goal is to get ALL files and sort them ingame based on their contained text.

So I need to be able to get all files within that directory and, if possible, specify that they’re .txt files but I imagine I may be able to get away with checking if the filename’s last 4 characters are .txt but I’m unsure if all text files will have that in the name just because it’s the file’s extension.

Most of my progress has been based on Rama’s work but none of it seems to be functional in my project as stated above.

Code that kinda works but only in editor and seemingly can’t give me access to any sub directories.