문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top