Sunday, July 28, 2013

.NET - Build Files into Executables

Visual Studio has a really awesome feature that can bundle files into compiled programs.  Those files can be accessed in code in the form of an UnmanagedMemoryStream or via a more specific resource descriptor.  To do so, add the file to the project and set its build action to "embedded resource."  The files can be found in the My.Resources namespace and read with a StreamReader.  For some file types, like images, there exist classes to automatically create an instance of the appropriate type.

No comments:

Post a Comment