• 0

C# Windows Store enumerate folders or files


Question

Hello gang,

Making my first Windows Store app and I am attempting to be able to enumerate through the files and/or folders in the KnownFolders.MusicLibrary or other known folder.

I have this, but this does not get what I want.


var MusicFolders = Windows.Storage.KnownFolders.MusicLibrary.CreateFolderQuery();
[/CODE]

Clues?

2 answers to this question

Recommended Posts

  • 0


var options = new QueryOptions(CommonFileQuery.OrderByMusicProperties);
var files = await KnownFolders.MusicLibrary.CreateFileQueryWithOptions(options).GetFilesAsync();[/CODE]

*should* give you a deep, flat list of all the files in the music library, using the search indexer.

If you want non indexed version, pass in "KnownFolders.MusicLibrary" to this

[CODE]
async static Task RecursiveCrawl(IStorageFolder folder)
{
var folders = await folder.GetFoldersAsync();
if (folders != null) foreach (var fol in folders) await RecursiveCrawl(fol);

var files = await folder.GetFilesAsync();
foreach (var fi in files)
{
// Do stuff
}
}
[/CODE]

Thanks to the runtime brokers restrictions however you won't get any hidden files returned, no matter what you do. So no folder.jpg 's coming out.

It's preferable to use the first because it's many leagues faster. Unfortunately though, for reasons I may never know, I've had a number of emails from users who have had the former query await forever. Probably a corrupt search index, but there's no way of you knowing that.

This topic is now closed to further replies.
  • Posts

    • MusicBee 3.6.9668 by Razvan Serea MusicBee is an application geared toward managing extensive music collections, easy to use and with a comprehensive feature set. It makes it easy to organize, find, and play music files on your computer, on portable devices, and on the Web. It provides playback of a wide range of audio formats, smart playlists with the ability to discover and play new music from the web, advanced tag editing with automated artwork and tag look up, folder monitoring, automated file re-organization, portable device synchronization, and secure CD ripping with AccurateRip verification. MusicBee features: Supported formats: MP3, AAC, M4A, MPC, OGG, FLAC, APE, TAK, WV, WMA and WAV. Audio CDs: Audio CD playback and ripping (with CD-Text capabilities) is supported. CD tracks can be ripped (in fast or secure mode) as individual files or as a single album with embedded cuesheet. Conversion: Conversion from and to all supported formats as metadata are preserved. Synchronization of tags only (in case that the output file already exists) instead of reencoding is possible. ReplayGain support: both playback and calculation. File Organization: Organization and renaming of music files into folders and files based on tag values such as artist, album, name, track number, etc. that can be specified. MusicBee can do this automatically for all files in a music library or the user can choose the files or folders themselves. Web Browsing: Browsing of the web using Mozilla's XULRunner environment. Scrobbling: Tracks played from MusicBee can optionally be scrobbled to Last.fm. Customizable user interface layout. Customizable keyboard shortcuts. MiniLyrics support Download: MusicBee 3.6.9668 | MusicBee Portable | ~9.0 MB (Freeware) Download: Windows Store Edition View: MusicBee Home page | Release Notes | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • On xiaomi hyperos there's also an option to disable google assistant. I've got everything disabled. Only thing I do have installed is a web wrapped for duck.ai which claims to let you use various AIs anonymously
    • I need to understand the rationale of not shipping all of these K2 improvements in a single update/release. It's giving "we will fix Windows 11 but no commitments". It seems to me that they just announce these improvements just to appease the community.
    • The term "RTM" is long gone starting with Windows 10. Every current release is a GA build. This is the result of MS making Windows as a Service (WaaS).
    • Looks like no official TBW rating, which should be a required listing in my opinion for sites like Amazon (hell, put it on the box too.)
  • Recent Achievements

    • Conversation Starter
      sumytbe earned a badge
      Conversation Starter
    • One Year In
      B4dM1k3 earned a badge
      One Year In
    • One Year In
      DarkWun earned a badge
      One Year In
    • Dedicated
      Almohandis earned a badge
      Dedicated
    • Dedicated
      JuvenileDelinquent earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      516
    2. 2
      +Edouard
      186
    3. 3
      PsYcHoKiLLa
      87
    4. 4
      Michael Scrip
      79
    5. 5
      Steven P.
      73
  • Tell a friend

    Love Neowin? Tell a friend!