Search code examples
windows-phone-8isolatedstoragefile

where is my static content in windows phone 8 app?


I have Windows Phone 8 app in which I want to include my own 10 MP3s. I included them in /Assets, but a call like

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
    songs = store.GetFileNames("*.mp3").ToList();
    Console.WriteLine("Found  {0} files ", songs.Count());
}

keeps returning that the # of MP3s in my store is 0.

I tried putting the MP3s in Content, Assets, Resources and set Copy Always option, but to no avail.

Any help will be appreciated.


Solution

  • if you set your files as "Embedded Resource", you can get a list of files at runtime.

    Here is how you can do this:

    1. Set the Build Action of your files as "Embedded Resource".
    2. Use Assembly.GetCallingAssembly().GetManifestResourceNames() to enumerate the resources names

      string[] GetResourcesNames()
      {
          return Assembly.GetCallingAssembly().GetManifestResourceNames();
      }