Rich
Rich

Reputation: 36816

Including files in Silverlight app and retrieving in code as raw byte stream

If I include files in my Silverlight app and need to load them as raw byte arrays programatically, which Build Action should I set them as, and how do I refer to them? If they are included as Content, can I load them by path as a regular file? If I include them as Resource is there a collection of embedded resources where I can grab a reference to them? What are the pros and cons and differences between the two approaches?

Upvotes: 0

Views: 216

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1501053

Set the Build Action to "Embedded Resource" and use Assembly.GetManifestResourceStream to load them. I believe the "Resource" build action is meant for resource files (resx) which are slightly different, although I've never been entirely sure :)

If you include them as regular content, you may have difficulty deploying the files - I'm not entirely sure, to be honest. (That's a Silverlight-specific area.)

Personally I like using Embedded Resources so long as you don't need to be able to update them independently - at that point it's helpful to have them on disk as normal files.

Upvotes: 3

Related Questions