Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:26:42+00:00 2026-06-16T06:26:42+00:00

I’ve just started discovering Windows StoreApps (that’s what Microsoft calls it) and I’m following

  • 0

I’ve just started discovering Windows StoreApps (that’s what Microsoft calls it) and I’m following the sample code here about using the FolderPicker.

I want to Iterate through the folder and read all the sub-folders and files.

There are two functions I’ve looked at which I thought are what I need but I’m not able to do it properly after trying hours.

In the link above, the line which says:

WinJS.log && WinJS.log("Picked folder: " + folder.name, "sample", "status");

I tried to dig deeper in the folder with something like:

folder.getFoldersAsync().then(function (folderItem) {
    document.getElementById('musicFolder').innerHTML += folderItem.length + " folders)<br/>";
    folderItem.forEach(function (x) {
        document.getElementById('musicFolder').innerHTML += "--" + x.name + "<br/>";
        x.getFilesAsync().then(function (items) {
            document.getElementById('musicFolder').innerHTML += items.length + " files"+"<br>";
        });
    });
});

UPDATE:

I have been struggling but can’t get the stuff organized while iterating folders and sub-folders.

@Damir’s code doesn’t dig deepest folder. We need a recursive function. I could come up with the following function but as I said result is not organized

function scanFolder(folder) {
    var isInc = false;
    folder.getFoldersAsync().then(function (folderItem) {
        if (folderItem.length > 0) {
            folderItem.forEach(function (x) {
                if (!isInc) {
                    isInc = true;
                    hyphen += "-";
                }
                document.getElementById('musicFolder').innerHTML += hyphen + x.name + "</br>";
                x.getFilesAsync().then(function (items) {
                    items.forEach(function (item) {
                        allTracks.push({
                            name: item.name,
                            path: item.path
                        });
                        document.getElementById('musicFolder').innerHTML += hyphen +"-"+ item.name + "</br>";
                    });
                }).done(function () {
                    scanFolder(x);
                });
            });
        }
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:26:43+00:00Added an answer on June 16, 2026 at 6:26 am

    You want to read all the subfolders and the files inside them? Something like this should work:

    folder.getFoldersAsync().then(function (folderItem) {
        document.getElementById('musicFolder').innerHTML += "(" + folderItem.length + " folders)<br/>";
        folderItem.forEach(function (x) {
            x.getFilesAsync().then(function (items) {
                document.getElementById('musicFolder').innerHTML += "--" + x.name + " (" + items.length + " files)<br>";
                items.forEach(function(item) {
                    document.getElementById('musicFolder').innerHTML += "----" + item.name + "<br>";
                });
            });
        });
    });
    

    EDIT:

    There’s actually no need for recursion to recursively scan a folder and its subfolders in WinRT. You can use StorageFolder.CreateFileQueryWithOptions() instead:

    var options = new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.defaultQuery, ['*']);
    options.folderDepth = Windows.Storage.Search.FolderDepth.deep;
    folder.createFileQueryWithOptions(options).getFilesAsync().then(function (files) {
        var paths = new Array();
        files.forEach(function(file) {
            paths.push(file.path);
        });
        paths.sort();
        paths.forEach(function(path) {
            document.getElementById('musicFolder').innerHTML += path + "<br>";
        });
    });
    

    From here on you can transform the flat list of files to whatever you need instead of just printing out their path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am reading a book about Javascript and jQuery and using one of the
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.