Various technical articles, IT-related tutorials, software information, and development journals
Wednesday, May 23, 2018
Getting the contents of a .NET embedded resource
Setting a file's Build Action to Embedded Resource in Visual Studio causes the file to be embedded in the assembly, but it's not obvious how to actually access the file's data. A Stream for a given resource can be acquired through the GetManifestResourceStream function on an assembly, most likely Assembly.GetExecutingAssembly() for the current one. The resource name is qualified by the root namespace, so a project with a root namespace of SomeProgram with an embedded file named TheDocument.txt would find that file at SomeProgram.TheDocument.txt.
Labels:
misc
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment