Read files with Build Action = Content

windows-phone-7

Solution

Items with `Build Action` of `Content` are included in the package (.xap) file and are accessible via a `Uri`. You still use `Application.GetResourceStream()` to get at a stream

var si = Application.GetResourceStream(new Uri("FileName.ext", UriKind.Relative));
using (var sr = new StreamReader(si.Stream))
{
    //blah
}

This is fairly well documented in the MSDN help. Application.GetResourceStream

Problem

I have some files in my project that have `Build Action` set to `Content`. How can I obtain a stream to read these content files? PS: Setting the `Build Action` to `Resource` and then reading the file via `Application.GetResourceStream()` is not an option.

Original source