I have the following code. It's not finding my resource:
string filename = "Resources/Functions.plist";
Uri fileUri = new Uri(filename, UriKind.Relative);
StreamResourceInfo sr = Application.GetResourceStream(fileUri);
But after the above executes, sr is null. Not good.
I do have a file named "Functions.plist" in a directory named "Resources", which is a subdirectory of my project directory. When I right click it in the solution explorer, I see its build action as "Resource" and its copy to output directory as "copy if newer".
Here is the portion of the .csproj file that loads it, or at least I think it does:
<ItemGroup>
// AppManifest and WMAppManifest here
<Resource Include="Resources\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
What could be wrong?
What I usually do is load a random image in the designer, and then I copy the auto-generated path from the XAML code and use it as a template for my own .CS code.
Of course, if it is not an image, I use the path as a template for other objects.
It might also help if you select the "Always Copy" option.
I think you can get resouces like this.
Because WP7's file seperator is slash, not back slash.
I hope this could help.
Turns out what I had to do was use the following to include the files in the project:
I'm not sure, but the key may have been changing "Resource" to "Content".
For resources you the uri format is slightly different that content, what you'll need is something like:
The first part tells the system which assembly to look for the resource in. If you don't know the assmebly name you should be able to find it in the project properties screen.