0

I have a project written in C++ that depends on a local file. At runtime, I read that file from disk. When I build the project an .exe file is generated, but I still need that file on disk for the program to work. I use Visual Studio 2019 to build the program. Is it possible to embed that file into the executable?

The final goal is to ship only the executable file, so that it can be executed on other computers that do not have that file on local disk.

anegru
  • 1,023
  • 2
  • 13
  • 29
  • What is this file for? What is its purpose? Is it supposed to be editable by your program? Editable by the users? Why not create a simple installer that contains both files and which makes sure both are installed in their correct places? And is your program Windows only, or should it be portable to different platforms and operating systems? – Some programmer dude Jul 29 '19 at 13:47
  • Embedding resources in a program is a well-trodden topic. What research have you done so far? – Lightness Races in Orbit Jul 29 '19 at 13:53
  • 1
    https://stackoverflow.com/questions/2933295/embed-text-file-in-a-resource-in-a-native-windows-application –  Jul 29 '19 at 13:54
  • 1
    What have you against using an installer? The installer can package the file with the executable and install both on the target machine. – Thomas Matthews Jul 29 '19 at 16:37

1 Answers1

1

If the file is needed only in read-only mode, you can put contents of this file in array.

smbear
  • 1,007
  • 9
  • 17