Search code examples
textembedc++builder

Embed Large Text File into C++Builder Windows App


I want to embed a large dictionary text file (more than 66k words of no more than 30 characters per word, with one word per line) into a C++Builder executable to run on Windows. How can that be done?


Solution

  • Rather than embed the text file into the executable itself, you could just store the file in the same folder as the executable (or any other folder of your choosing), and then load the file at runtime using a TStringList object using its LoadFromFile() method.

    Otherwise, if you really want to embed the file, you can store its content in a resource in the executable, by referring to the file with an .rc script added to the project (or, using the Project > Resources and Images... dialog), and then load the resource data into a TStringList object at runtime using its LoadFromStream() method with a TResourceStream. See Resource Files Support in Embarcadero's documentation for further details and an example.