StorageFolder.CreateFileQuery() | createFileQuery() method

Applies to Windows and Windows Phone

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

Syntax


var storageFileQueryResult = storageFolder.createFileQuery();

Parameters

This method has no parameters.

Return value

Type: StorageFileQueryResult

A query result object. Call the GetFilesAsync method of the query result to get the flat list of files. This method returns a list of type IReadOnlyList<StorageFile>. Each file is represented by an item of type StorageFile.

Remarks

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

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

To specify additional query options, call the CreateFileQueryWithOptions method.

To get items that are files or folders, call the CreateItemQuery method.

Examples

The following example gets a query result object that contains the files in the current folder by calling the CreateFileQuery() method.


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

// Get the files in the current folder.
var results = appFolder.createFileQuery();

// Iterate over the results and print the list of files
// to the Visual Studio Output window.
var filesInFolderPromise = results.getFilesAsync();
filesInFolderPromise.done(function getFilesSuccess(filesInFolder) {
    filesInFolder.forEach(function forEachFile(item) {
        console.log(item.name);
    });
});

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

See also

StorageFolder
CreateFileQuery(CommonFileQuery)
CreateFileQueryWithOptions

 

 

Show:
© 2014 Microsoft