How do access an embedded resource?

  • Thread starter Thread starter steve bull
  • Start date Start date
S

steve bull

I created an embedded resource by adding a Swatches.xml file to my Solution and then making it an embedded resource in
the VS IDE.

When I try to open a stream to the resource using GetManifestResourceStream("Swatches.xml") it fails.

Do I need to prefix the resource with a namespace or something?


Thanks,

Steve
 
steve bull said:
I created an embedded resource by adding a Swatches.xml file to my
Solution and then making it an embedded resource in
the VS IDE.

When I try to open a stream to the resource using
GetManifestResourceStream("Swatches.xml") it fails.

Do I need to prefix the resource with a namespace or something?

Yes, using . as a path separator. So if you have it in a directory
called Foo\Bar in a project with a default namespace of Widget, you'd
use

"Widget.Foo.Bar.Swatches.xml"

If you're not sure about something, look at the assembly with Reflector
- or GetManifestResourceNames.
 
Back
Top