0

Windows will allow you to have more than one music folder. How do I query the path for all the folders. I know that the following will get the current set folder but I want the others.

Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)

On my system this will produce the following folder. D:\Users\Bobby\Music. However that is not enough. I have another folder that is a music folder located at C:\Users\Bobby\SkyDrive\Music.

Basically I want to iterate all the folders in the MyMusic library from my Windows Store application.

enter image description here

Bobby Cannon
  • 6,665
  • 8
  • 33
  • 46
  • This is not a duplicate because I'm trying to access it via a Windows Store application using the WinRT API. Update question to state that requirement. – Bobby Cannon Mar 01 '13 at 18:38

1 Answers1

1

I figured it out. Here is how you access all MP3 music is a Windows Music library.

var options = new QueryOptions(CommonFileQuery.OrderByMusicProperties, new List<string> { ".mp3" });
options.SetThumbnailPrefetch(ThumbnailMode.MusicView, 256, ThumbnailOptions.UseCurrentScale);

var query = KnownFolders.MusicLibrary.CreateFileQueryWithOptions(options);
var files = await query.GetFilesAsync();

foreach (var file in files)
{
    /* Access MP3s */
}
Bobby Cannon
  • 6,665
  • 8
  • 33
  • 46