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 8819819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:27:30+00:00 2026-06-14T05:27:30+00:00

I am using JavaScript to develop a Windows 8 application. I need to get

  • 0

I am using JavaScript to develop a Windows 8 application. I need to get all the pictures (path of each and every picture) present in a given directory. How would I do this?

I have the following:

(function () {
    "use strict";
    var page = WinJS.UI.Pages.define("/html/scenario3.html", {
        ready: function (element, options) {
            document.getElementById("folder").addEventListener("click", pickFolder, false);
        }
    });

    function pickFolder() {
        // Clean scenario output
        WinJS.log && WinJS.log("", "sample", "status");

        // Verify that we are currently not snapped, or that we can 
        // unsnap to open the picker
        var currentState = Windows.UI.ViewManagement.ApplicationView.value;
        if (currentState === Windows.UI.ViewManagement.ApplicationViewState.snapped && !Windows.UI.ViewManagement.ApplicationView.tryUnsnap()) {
            // Fail silently if we can't unsnap
            return;
        }

        // Create the picker object and set options
        var folderPicker = new Windows.Storage.Pickers.FolderPicker;
        folderPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.desktop;
        // Users expect to have a filtered view of their folders depending on the scenario.
        // For example, when choosing a documents folder, restrict the filetypes to documents for your application.
        folderPicker.fileTypeFilter.replaceAll(["*"]);
        //folderPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);

        folderPicker.pickSingleFolderAsync().then(function (folder) {
            if (folder) {
                // Application now has read/write access to all contents in the picked folder (including sub-folder contents)
                // Cache folder so the contents can be accessed at a later time
                Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.addOrReplace("PickedFolderToken", folder);

                var pictures = Windows.Storage.KnownFolders.folder;
                pictures.getFilesAsync().done(function (images) {
                    console.log(images.length + " images found.");
                    WinJS.log && WinJS.log("Total Images: " + images.length, "sample", "status");
                });


            } else {
                // The picker was dismissed with no selected file
                WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
            }

        });
    }
})();

If I use the Above code it gives following error:

Unable to get property 'getFilesAsync' of undefined or null reference

  • 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-14T05:27:31+00:00Added an answer on June 14, 2026 at 5:27 am

    If you need to load pictures from the Pictures Library, you first need to check that this capability is enabled within the Capabilities tab inside the package.appxmanifest file of your project.

    Once enabled, you can refer to this library with the following:

    // 'pictures' is a reference to our Pictures Library
    var pictures = Windows.Storage.KnownFolders.picturesLibrary;
    

    Microsoft made the decision that any operation taking more than 50 milliseconds would need to be asynhronous, therefore to get the images from this library we must the following async method, and handle the results when the promise is resolved:

    // Get a list of files ('images') within our Pictures Library
    pictures.getFilesAsync().done(function( images ) {
        console.log( images.length + " images found." );
    });
    

    From here you could iterate over the images found and handle them as you like.

    For more information, check out the Window.Storage namespace.

    Additionally, you may find the File access sample to be helpful as well.

    Update

    From your updated code I can see that you’re permitting the user to select a folder of their choosing. With this you’d need to set the fileTypeFiltering and then pull the images once the pickSingleFolderAsync promise resolves:

    // Prompt user to select a folder
    var picker = Windows.Storage.Pickers.FolderPicker();
    
    // Which file types will we be showing?
    picker.fileTypeFilter.append(".jpg");
    
    // Grab the selected folder, reference as 'folder'
    picker.pickSingleFolderAsync().then(function (folder) {
        // Get files within selected folder as 'files'
        folder.getFilesAsync().then(function (files) {
            // Output number of files found
            console.log(files.length + " files found.");
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop a coupon application using javascript, am new to this. I need to
I am new to develop Windows 8 app using HTML/Javascript. I want to create/remove
I am planning to develop something small in windows 8 using HTML/JavaScript project type.
I want develop some web product with using javascript 3d library like three.js But
I am using HTML 5 to develop a few things and inserting Facebook JavaScript
I'm currently using PHP, JAVASCRIPT, MYSQL, XHTML, CSS to develop my site. Note that
I'm using the old Rest API (and old Javascript SDK) to develop an iframe
I am using the Adobe AIR SDK to develop an HTML/JavaScript app that needs
I want to develop fleet tracking app using HTML5,JavaScript, Couch DB for a construction
Possible Duplicate: How can I develop for iPhone using a Windows development machine? I've

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.