StorageFileQueryResult StorageFileQueryResult StorageFileQueryResult StorageFileQueryResult StorageFileQueryResult Class


Provides access to the results of a query of the files in the location that is represented by a storageFolder object. You can use storageFileQueryResult to enumerate the files in that storageFolder location.

public : sealed class StorageFileQueryResult : IStorageFileQueryResult, IStorageFileQueryResult2, IStorageQueryResultBase
struct winrt::Windows::Storage::Search::StorageFileQueryResult : IStorageFileQueryResult, IStorageFileQueryResult2, IStorageQueryResultBase
public sealed class StorageFileQueryResult : IStorageFileQueryResult, IStorageFileQueryResult2, IStorageQueryResultBase
Public NotInheritable Class StorageFileQueryResult Implements IStorageFileQueryResult, IStorageFileQueryResult2, IStorageQueryResultBase
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


This example demonstrates how to get a list of files from a storageFileQueryResult object.

// Set query options with filter and sort order for results
List<string> fileTypeFilter = new List<string>();
var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);

// Create query and retrieve files
var query = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
IReadOnlyList<StorageFile> fileList = await query.GetFilesAsync();
// Process results
foreach (StorageFile file in fileList)
    // Process file

// Set query options with filter and sort order for results
var fileTypeFilter = [".jpg", ".png", ".bmp", ".gif"];
var queryOptions = new Windows.Storage.Search.QueryOptions(search.CommonFileQuery.orderByName, fileTypeFilter);

// Create query and retrieve files
var query = Windows.Storage.KnownFolders.picturesLibrary.createFileQueryWithOptions(queryOptions);
query.getFilesAsync().done(function (files) {
    // Process results
    files.forEach(function (file) {
        // Process file

The query variable gets the storageFileQueryResult that is used to retrieve files that meet the criteria of the query.


You need the Pictures library capability to access the library using KnownFolders.PicturesLibrary. To learn more about capabilities and file access, see File access permissions.



Although it's not attributed with marshalling_behavior(agile), this class can be treated as agile.

You can get a storageFileQueryResult object by calling the following methods from a storageFolder or a folderInformation object:


Folder Folder Folder Folder Folder

Gets the folder that was queried to create the StorageFileQueryResult object. This folder represents the scope of the query.


ApplyNewQueryOptions(QueryOptions) ApplyNewQueryOptions(QueryOptions) ApplyNewQueryOptions(QueryOptions) ApplyNewQueryOptions(QueryOptions) ApplyNewQueryOptions(QueryOptions)

Modifies query results based on new QueryOptions.

FindStartIndexAsync(Object) FindStartIndexAsync(Object) FindStartIndexAsync(Object) FindStartIndexAsync(Object) FindStartIndexAsync(Object)

Retrieves the index of the file from the query results that most closely matches the specified property value (or file, if used with FileActivatedEventArgs.NeighboringFilesQuery ). The property that is matched is determined by the first SortEntry of the QueryOptions.SortOrder list.

GetCurrentQueryOptions() GetCurrentQueryOptions() GetCurrentQueryOptions() GetCurrentQueryOptions() GetCurrentQueryOptions()

Retrieves the query options used to determine query results.

GetFilesAsync() GetFilesAsync() GetFilesAsync() GetFilesAsync() GetFilesAsync()

Retrieves a list of all the files in the query result set.

GetFilesAsync(UInt32, UInt32) GetFilesAsync(UInt32, UInt32) GetFilesAsync(UInt32, UInt32) GetFilesAsync(UInt32, UInt32) GetFilesAsync(UInt32, UInt32)

Retrieves a list of files in a specified range.

GetItemCountAsync() GetItemCountAsync() GetItemCountAsync() GetItemCountAsync() GetItemCountAsync()

Retrieves the number of files in the set of query results.

GetMatchingPropertiesWithRanges(StorageFile) GetMatchingPropertiesWithRanges(StorageFile) GetMatchingPropertiesWithRanges(StorageFile) GetMatchingPropertiesWithRanges(StorageFile) GetMatchingPropertiesWithRanges(StorageFile)

Gets matching file properties with corresponding text ranges.


ContentsChanged ContentsChanged ContentsChanged ContentsChanged ContentsChanged

Fires when a file is added to, deleted from, or modified in the folder being queried. This event only fires after GetFilesAsync has been called at least once.

OptionsChanged OptionsChanged OptionsChanged OptionsChanged OptionsChanged

Fires when the query options change.

See Also