Trying to use MonoDevelop C# and embed a resources file (you know the one that has the .resources extension). I want the res file to contain strings for the app to read at runtime. I want to embed them in the EXE. But I cant figure out how to
Otherwise I guess I will abandon this idea and just put the text in my own text file. Thanks
There are two ways:
Easy way:
Go to solution sidebar and right click over the project name where you want the embedded resource to live in and in the contextual menu go to to Add -> Add Files and select the files you want to add. You can add a folder if you dont want them around the root project folder and the process is the same just right click over the added folder instead of the project name.
Once that is done select the file(s) and in the properties sidebar you'll see several options, change the "Build action" to "Embed as resource" and you are done. Actually you'll find more helpful options there.
Not so easy way:
Edit your .csproj file which is in the root folder of the project and add the files like this:
<ItemGroup>
<EmbeddedResource Include="Resources\file1.txt" />
<EmbeddedResource Include="Resources\file2.txt" />
</ItemGroup>
Note that there is a backslash to split folder name and filename. The ItemGroup element and its children should be anywhere below the main <Project>
tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With