Expand Minimize

StorageFolder.CreateItemQueryWithOptions | createItemQueryWithOptions method

Applies to Windows only

Gets a query result object that contains the files and subfolders in the current folder and, optionally, in the subfolders of the current folder. The results are based on the specified QueryOptions.

Syntax


Public Function CreateItemQueryWithOptions(
  queryOptions As QueryOptions 
) As StorageItemQueryResult

Parameters

queryOptions

Type: QueryOptions

The criteria that are applied to the query.

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 and, optionally, in the subfolders of the current folder, filtered and sorted based on the specified QueryOptions. 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.

Exceptions

ExceptionCondition
System.UnauthorizedAccessException

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

System.ArgumentException

You specified a value other than DefaultQuery from the CommonFileQuery or CommonFolderQuery enumeration for a folder that's not a library folder.

Remarks

In the following cases, this query is a shallow query that returns only files and subfolders in the current folder.

In the following cases, this query is a deep query that returns files and subfolders from the current folder and from its subfolders.

Note  

Some of the values from the CommonFileQuery enumeration can only be used with a library folder (such as the Pictures library) or the Homegroup folder. In addition to the DefaultQuery option, you can use only the OrderByName and OrderBySearchRank options with a folder that's not a library folder.

Values other than DefaultQuery from the CommonFolderQuery enumeration can only be used with a library folder (such as the Pictures library) or the Homegroup folder.

For a list of methods that identifies shallow queries and deep queries, see the Remarks in the topic GetItemsAsync.

To check whether the QueryOptions you want to specify are available for the current folder, call the folder's AreQueryOptionsSupported method. To check whether a specific CommonFileQuery or CommonFolderQuery is available, call the folder's IsCommonFileQuerySupported or IsCommonFolderQuerySupported method.

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

To get a query result object that contains the items in the current folder without configuring a QueryOptions object, call the CreateItemQuery method.

To get only files, call the CreateFileQueryWithOptions method. To get only folders, call the CreateFolderQueryWithOptions method.

On DLNA devices:  Don't set QueryOptions.FolderDepth to FolderDepth.Deep; deep queries do not work if you are querying files on a DLNA device.

For Windows Server 2012:  You must install indexer components to use some QueryOptions because indexer components are not installed by default.

Examples

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

No code example is currently available or this language may not be supported.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

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

Metadata

Windows.winmd

See also

StorageFolder

 

 

Show:
© 2014 Microsoft