Expand Minimize

StorageFolder.CreateItemQuery | createItemQuery method

Applies to Windows only

Gets a query result object that contains the files and subfolders in the current folder.


var storageItemQueryResult = storageFolder.createItemQuery();


This method has no parameters.

Return value

Type: StorageItemQueryResult

A query result object. Call the GetItemsAsync method of the query result to get the files and subfolders in the current folder. This method returns a list of type IReadOnlyList<IStorageItem>. Each file or folder is represented by an item of type IStorageItem.

To work with the returned items, call the IsOfType method of the IStorageItem interface to determine whether each item is a file or a folder. Then cast the item to a StorageFolder or StorageFile.



You don't have permission to access the contents of the current folder.


This query is a shallow query that returns only items in the current folder. For a list of methods that identifies shallow queries and deep queries, see the Remarks in the topic GetItemsAsync.

You can also get a list of items in the current folder asynchronously by calling one of the GetItemsAsync methods.

To specify additional query options, call the CreateItemQueryWithOptions method.

To get only files, call the CreateFileQuery method. To get only folders, call the CreateFolderQuery method.


The following example shows how to get the files and subfolders in the current folder by calling the CreateItemQuery() method.

// Get the app's installation folder.
var appFolder = Windows.ApplicationModel.Package.current.installedLocation;

// Get the items in the current folder.
var itemsInFolder = appFolder.createItemQuery();

// Iterate over the results and print the list of items
// to the Visual Studio Output window.
var itemsPromise = itemsInFolder.getItemsAsync();
itemsPromise.done(function getItemsSuccess(items) {
    items.forEach(function forEachItem(item) {
        var StorageItemTypes = Windows.Storage.StorageItemTypes;
        if (item.isOfType(StorageItemTypes.folder)) {
            console.log("Folder:", item.name);
        } else {
            console.log("File:", item.name, item.dateCreated);


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported


Windows::Storage [C++]



See also




© 2014 Microsoft