Question

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.

Was it helpful?

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();
    }
    

OTHER TIPS

The files is not copied to isolated store for your app, but you can get them by the uri:

var mymp3file = new Uri("Assets/HomersDoh.mp3", UriKind.RelativeOrAbsolute);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top