开发者

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

开发者 https://www.devze.com 2023-01-14 05:46 出处:网络
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开发者_StackOverflow社区 I refer to them?If they a

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开发者_StackOverflow社区 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消