I need to load some image files in my application, and I want to just build them into the application instead of having the user point to their path. So I think I need a resource file. But I’m having a little trouble figuring out how to create a resource file and add it to my application.
Share
You can add the file to your project by choosing Add Existing Item from the project menu. Then, in properties for the file (hit F4), choose that Build Action should be “Embedded Resource”. Then your file will be embedded in the assembly.
You can get to the file by using Assembly.GetManifestResourceStream:
The “SomeType” should be in the same assembly as the embedded resource, and you will need to specify the name of the file relative to the namespace location of the type.