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.

Était-ce utile?

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

Autres conseils

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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top