I\'m including a number of images as \"Content\" in my deployed XAP for Mango.
I\'d like to enumerate these at runtime - is there any way to do this?
I\'ve t
There is no way to enumerate the files set as "Content".
However, there is a way to enumerate files at runtime, if you set your files as "Embedded Resource".
Here is how you can do this:
Assembly.GetCallingAssembly().GetManifestResourceNames() to
enumerate the resources namesAssembly.GetCallingAssembly().GetManifestResourceStream(resName)
to get the file streams.Here is the code:
public void Test()
{
foreach (String resName in GetResourcesNames())
{
Stream s = GetStreamFromEmbeddedResource(resName);
}
}
string[] GetResourcesNames()
{
return Assembly.GetCallingAssembly().GetManifestResourceNames();
}
Stream GetStreamFromEmbeddedResource(string resName)
{
return Assembly.GetCallingAssembly().GetManifestResourceStream(resName);
}
EDIT : As quetzalcoatl noted, the drawback of this solution is that images are embedded in the DLL, so if you a high volume of images, the app load time might take a hit.