In .net 4.5 i was able to add a resource file to my project, add images as bitmaps to this resource file and access them by Properties.Resources.ImageName. How do i compile images in 4.6 dnx?
Thanks in advance!
You can specify the files that will be compiled into the assembly under the "resources" section in project.json, like so:
"resources": [
"path/to/yourfile.png"
],
After which, assuming your project's name is YourProject, the file can be accessed via:
const string path = "YourProject.path.to.yourfile.png";
Assembly.GetExecutingAssembly().GetManifestResourceStream(path)
Note how the slashes in the filesystem path are converted into periods in the resource path.
Note: In 1.0.0-rc1 (and possibly -beta8, haven't checked) the project setting is renamed from resources
to resource
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