• 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

    • I made a new Cinematic/Trailer for the game, this will be the intro, still a work in progress!  I also updated the Steam page with a ton of new screenshots! 👀 https://store.steampowered.com/app/3925340/Incoherence_Dark_Rooms/  
    • Closed-loop cooling and a custom 800G network protocol let the $7.3B campus run as one AI training machine. Microsoft confirmed June 23, 2026, that its Fairwater campus in Mount Pleasant, Wisconsin, is fully operational — and the engineering behind it makes the facility something fundamentally different from every data center that came before it. Where conventional cloud infrastructure racks up general-purpose servers and parcels out workloads to each one independently, Fairwater links hundreds of thousands of NVIDIA GB200 Blackwell GPUs into a single, coherent cluster using a two-story building design, 800-gigabit-per-second Ethernet fabric, and a proprietary networking protocol co-developed with OpenAI and NVIDIA. The result, according to Microsoft, is the closest thing to a purpose-built AI supercomputer that any company has ever placed in commercial operation. https://www.techtimes.com/articles/319205/20260627/microsoft-opens-fairwater-wisconsin-ai-campus-runs-one-supercomputer-via-800g-ethernet.htm  
    • Last comment on this article Decades of serving as a global manufacturing hub have allowed China to build a massive talent pool in the production sector that is almost unmatched worldwide. Decades of using "forced labor" have allowed China................. UN experts alarmed by reports of forced labour of Uyghur, Tibetan and other minorities across China https://www.ohchr.org/en/press...ibetan-and-other-minorities
  • Recent Achievements

    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
    • Week One Done
      Excellence2025 earned a badge
      Week One Done
    • Week One Done
      flexorcist earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      +Edouard
      207
    3. 3
      PsYcHoKiLLa
      151
    4. 4
      Steven P.
      73
    5. 5
      macoman
      62
  • Tell a friend

    Love Neowin? Tell a friend!