4 ms·
> .NET does allow you embed files directly into your project and read in those files but it's a lot of confusing boilerplate. I think "a lot" is a bit of overs
by bob1029 5y ago
> .NET does allow you embed files directly into your project and read in those files but it's a lot of confusing boilerplate.
I think "a lot" is a bit of overstatement considering the amount of power you have here. My implementations around embedded resources usually look like this same set of 5 lines:
var assembly = Assembly.GetExecutingAssembly();
using var stream = assembly.GetManifestResourceStream("My.Embedded.Resource.png");
using var memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
var myPngBytes = memoryStream.ToArray();