Hacker News new | ask | show | jobs
by eterm 174 days ago
C# / .NET has always had that abililty.

  <EmbeddedResource Include="/path/to/file.txt" /> 
Then you can read that file from the assembly with:

  assembly.GetManifestResourceStream
I'm not sure what's awkward about that, but it's nothing new.

Discoverability for this is in visual studio, if you go to file properties there's a drop-down where you choose between Content, EmbeddedResource, Ignore, etc.

That determines what happens in compile, whether it is copied to output directory, compiled into the binary, etc.

1 comments

The Stream is awkward. It needs to be processed either once at startup or lazy on access, or every time it's used (allocations!). Also discovering multiple files is awkward.