Search code examples
c#embedded-resource

How to store strings in the executable?


I can't use Settings because there's an external file. Is there any way to embed settings or otherwise embed data within the executable?

I need to be able to launch the application and have data saved from within and not loaded elsewhere.


Solution

  • What kind of data are you talking about? A file of strings? A single String of text? If it's a file, changing the "Build Action" property of the file to "Embedded Resource" will in fact embed the file.

    If they are single strings, add a new file to your project, a Resources File (.resx), and mark that file as an "Embedded Resource".

    Here's a similar question where there is code to show how to read a specific string: read string from .resx file in C#