Storage​Item​Query​Result Storage​Item​Query​Result Storage​Item​Query​Result Storage​Item​Query​Result Class

Definition

Provides access to the results of a query that lists all items including files and folders (or file groups) in the folder being queried (which is represented by a storageFolder ). You can use storageItemQueryResult to enumerate the files and folders in that storageFolder.

public : sealed class StorageItemQueryResult : IStorageItemQueryResult, IStorageQueryResultBasepublic sealed class StorageItemQueryResult : IStorageItemQueryResult, IStorageQueryResultBasePublic NotInheritable Class StorageItemQueryResult Implements IStorageItemQueryResult, IStorageQueryResultBase// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Note

Although it's not attributed with marshalling_behavior(agile), this class can be treated as agile. For more info, see Threading and Marshaling (C++/CX).

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

Properties

Folder Folder Folder Folder

Gets the folder originally used to create the StorageItemQueryResult object. This folder represents the scope of the query.

public : StorageFolder Folder { get; }public StorageFolder Folder { get; }Public ReadOnly Property Folder As StorageFolder// You can use this property in JavaScript.

Methods

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

Modifies query results based on new QueryOptions.

public : void ApplyNewQueryOptions(QueryOptions newQueryOptions)public void ApplyNewQueryOptions(QueryOptions newQueryOptions)Public Function ApplyNewQueryOptions(newQueryOptions As QueryOptions) As void// You can use this method in JavaScript.
Parameters
newQueryOptions
QueryOptions QueryOptions QueryOptions QueryOptions

The new query options.

Remarks

This method causes the OptionsChanged event to fire.

When this method returns, subsequent calls to GetItemsAsync or GetItemCountAsync will reflect the results of the new QueryOptions.

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

Retrieves the index of the item from the query results that most closely matches the specified property value. The property that is matched is determined by the first SortEntry of the QueryOptions.SortOrder list.

public : IAsyncOperation<unsigned short> FindStartIndexAsync(PlatForm::Object value)public IAsyncOperation<uint> FindStartIndexAsync(Object value)Public Function FindStartIndexAsync(value As Object) As IAsyncOperation( Of uint )// You can use this method in JavaScript.
Parameters
value
PlatForm::Object Object Object Object

The property value to match when searching the query results. The property to that is used to match this value is the property in the first SortEntry of the QueryOptions.SortOrder list.

Returns

When this method completes successfully it returns the index of the matched item in the query results.

Examples

This example shows how to find the first item that has an album title that begins with an "R" in a set of query results that contains albums sorted by title.


QueryOptions queryOptions = new QueryOptions();
queryOptions.FolderDepth = FolderDepth.Deep;
queryOptions.IndexerOption = IndexerOption.OnlyUseIndexer;
SortEntry album = new SortEntry();
album.AscendingOrder = true;
album.PropertyName = "System.Music.AlbumTitle";
queryOptions.SortOrder.Add(album);

StorageFolderQueryResult queryResult = musicFolder.CreateItemQueryWithOptions(queryOptions);
var firstIndex = await queryResult.FindStartIndexAsync("R");
var queryOptions = new Windows.Storage.Search.QueryOptions();
queryOptions.folderDepth = Windows.Storage.Search.FolderDepth.deep;
queryOptions.indexerOption = Windows.Storage.Search.IndexerOptions.onlyUseIndexer;
queryOptions.sortOrder.append({
 ascendingOrder: true,
 propertyName: "System.Music.AlbumTitle"
});

var queryResult = Windows.Storage.KnownFolders.picturesLibrary.createFolderQueryWithOptions(queryOptions);
var firstIndex = queryResult.findStartIndexAsync("R");

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

Retrieves the query options used to determine query results.

public : QueryOptions GetCurrentQueryOptions()public QueryOptions GetCurrentQueryOptions()Public Function GetCurrentQueryOptions() As QueryOptions// You can use this method in JavaScript.
Returns

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

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

public : IAsyncOperation<unsigned short> GetItemCountAsync()public IAsyncOperation<uint> GetItemCountAsync()Public Function GetItemCountAsync() As IAsyncOperation( Of uint )// You can use this method in JavaScript.
Returns

When this method completes successfully, it returns the number of items in the location that match the query.

See Also

GetItemsAsync() GetItemsAsync() GetItemsAsync() GetItemsAsync()

Retrieves a list of all the items (files and folders) in the query results set.

public : IAsyncOperation<IVectorView<IStorageItem>> GetItemsAsync()public IAsyncOperation<IReadOnlyList<IStorageItem>> GetItemsAsync()Public Function GetItemsAsync() As IAsyncOperation( Of IReadOnlyListIStorageItem )// You can use this method in JavaScript.
Returns
IAsyncOperation<IVectorView<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>>

When this method completes successfully, it returns a list (type IVectorView ) of items. Each item is the IStorageItem type and represents a file, folder, or file group.

In this list, files are represented by storageFile objects, and folders or file groups are represented by storageFolder objects.

See Also

GetItemsAsync(UInt32, UInt32) GetItemsAsync(UInt32, UInt32) GetItemsAsync(UInt32, UInt32) GetItemsAsync(UInt32, UInt32)

Retrieves a list of items (files and folders) in a specified range.

public : IAsyncOperation<IVectorView<IStorageItem>> GetItemsAsync(unsigned int startIndex, unsigned int maxNumberOfItems)public IAsyncOperation<IReadOnlyList<IStorageItem>> GetItemsAsync(UInt32 startIndex, UInt32 maxNumberOfItems)Public Function GetItemsAsync(startIndex As UInt32, maxNumberOfItems As UInt32) As IAsyncOperation( Of IReadOnlyListIStorageItem )// You can use this method in JavaScript.
Parameters
startIndex
unsigned int UInt32 UInt32 UInt32

The zero-based index of the first item to retrieve. This parameter defaults to 0.

maxNumberOfItems
unsigned int UInt32 UInt32 UInt32

The maximum number of items to retrieve. Use -1 to retrieve all items. If the range contains fewer items than the max number, all items in the range are returned.

Returns
IAsyncOperation<IVectorView<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>> IAsyncOperation<IReadOnlyList<IStorageItem>>

When this method completes successfully, it returns a list (type IVectorView ) of items. Each item is the IStorageItem type and represents a file, folder, or file group.

In this list, files are represented by storageFile objects, and folders or file groups are represented by storageFolder objects.

Remarks

You can use the isOfType method on both types of storage objects to find out whether an item is a storageFile or storageFolder object.

For C#/C++/VB: After you know whether the item is a StorageFile or StorageFolder, you can then cast the item to the appropriate type in order to access properties and methods specific to that object.

Use this overload to improve system performance by presenting a virtualized view of the query results that includes only the necessary subset of folders. For example, if your app displays many items in a gallery you could use this range to retrieve only the items that are currently visible to the user.

See Also

Events

ContentsChanged ContentsChanged ContentsChanged ContentsChanged

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

public : event TypedEventHandler ContentsChanged<IStorageQueryResultBase,  object>public event TypedEventHandler ContentsChanged<IStorageQueryResultBase,  object>Public Event ContentsChanged<IStorageQueryResultBase,  object>// You can use this event in JavaScript.

Remarks

If you register a handler for this event, keep that handler registered while you suspend your app (in response to oncheckpoint or Suspending ). Your app will not receive ContentsChanged events while it is suspended and when your app resumes it will receive a single event that aggregates all of the changes if any occurred.

Additionally, keep in mind that registering and removing event handlers are synchronous operations and might cause your app to stop responding briefly if you execute them on your app's UI thread. Wherever possible, use a thread other than your app's UI thread to register and unregister these event handlers.

OptionsChanged OptionsChanged OptionsChanged OptionsChanged

Fires when the query options change.

public : event TypedEventHandler OptionsChanged<IStorageQueryResultBase,  object>public event TypedEventHandler OptionsChanged<IStorageQueryResultBase,  object>Public Event OptionsChanged<IStorageQueryResultBase,  object>// You can use this event in JavaScript.

See Also