Retrieving Embedded Resources in VS
Embedding resources in my assembly and thenretrievingthemis somewhat easier than the convoluted method I have been using to date.
Now I find that I can in VS, simply add an existingresource (say an XSLT document) to a project, and set the "Build Action" property for the file to "Embedded Resource".
I can then easily retrieve the resource programatically as follows:-
Stream s = myAssembly.GetManifestResourceStream(resourceName);
Perfect - ready to instantiate an XmlTextReader with the stream.
The only non-intuitive thing is the resource name. It should be named for retrieval as the projects default namespace plus, if the file has been added at the root level of your project - the name of the file. If loaded into a folder off the the root project folder, the file name should be prepended with that folder name.
For example a project might have a default namespaceof Alintex.Script. Ifone placed a document named psf.xslt into the root folder of the project,one would specify the resource name as Alintex.Script.psf.xslt. If I placed the psf.xslt document into a folder named "Resources" off the project root, then I would specify the resource name as Alintex.Script.Resources.psf.xslt