信息
您所需的主题如下所示。但此主题未包含在此库中。

StorageFolderQueryResult Class

提供对某个查询的结果的访问,该查询列出所查询文件夹(由 storageFolder 表示)中的文件夹(或文件组)。 可以使用 storageFolderQueryResult 来枚举文件夹或该文件夹中的文件组。

语法


var storageFolderQueryResult = storageFolder.createFolderQuery();

特性

[MarshalingBehavior(Agile)]
[Version(0x06020000)]

成员

StorageFolderQueryResult类 具有这些类型的成员:

事件

StorageFolderQueryResult类 具有这些事件。

事件说明
ContentsChanged Fires when a file is added to, deleted from, or modified in the folder being queried.
OptionsChanged Fires when the query options change.

 

方法

The StorageFolderQueryResult 类 具有这些方法。 对于 C#、Visual Basic 和 C++,它还继承方法于Object 类.

方法说明
ApplyNewQueryOptions Modifies query results based on new QueryOptions.
FindStartIndexAsync Retrieves the index of the folder 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.
GetCurrentQueryOptions Retrieves the query options used to determine query results.
GetFoldersAsync() Retrieves a list of all the folders (or file groups) in the result set.
GetFoldersAsync(UInt32, UInt32) Retrieves folders (or file groups) in a specified range.
GetItemCountAsync Retrieves the number of folders (or file groups) in the set of query results.

 

属性

StorageFolderQueryResult类 具有这些属性。

属性访问类型说明

Folder

只读Gets the folder originally used to create the StorageFolderQueryResult object.

 

备注

通过调用来自 storageFolderfolderInformation 对象的以下方法来获取 storageFolderQueryResult 对象:

有关演示如何使用 storageFolderQueryResult 对象的更多代码示例,请参见文件夹枚举示例

若要获取 StorageFolderQueryResult 对象以枚举某个位置中的文件夹或文件组,您必须获取表示位置的 storageFolder,然后创建一个文件夹查询。

Windows Phone 8

此 API 不实现,但是调用时会引发异常。请参见 Windows Phone 运行时 API

示例

此示例演示如何从 storageFolderQueryResult 对象中获取列表文件夹(或文件组)。



// Get the Pictures library, then rearrange it by month
var picturesLibrary = Windows.Storage.KnownFolders.picturesLibrary;

// Set query options to create groups of files within result
var queryOptions = new QueryOptions(Windows.Storage.Search.CommonFolderQuery.GroupByMonth);

// Create query and retrieve result
var queryResult = picturesLibrary.createFolderQuery(Windows.Storage.Search.CommonFolderQuery.groupByMonth);
queryResult.getFoldersAsync().done(function(folders) {
    // Process file groups (or folders)

    // Create an array of promises that will asynchronously
    // retrieve the files for each file group
    var promises = folders.map(function (folder) {
        return folder.getFilesAsync();
    });

    // Aggregate the results of multiple asynchronous operations
    // so that they are returned after all are completed. This
    // ensures that the groups are displayed in order.
    WinJS.Promise.join(promises).done(function (folderContents) {
        // Process the contents of each file group (or folder)

        for (var i in folderContents) {
            // Process the group/folder at index i of folderContents

            // Display the group name
            var group = outputResultGroup(folders.getAt(i).name);
            // Display the items in the group 
            outputItems(group, folderContents[i]);
        }
    });
});

The queryResult 变量获取检索符合查询标准的文件组(或文件夹)所使用的 storageFolderQueryResult

注意  使用 KnownFolders.PicturesLibrary,需要图片库功能访问该库。要了解关于功能和文件访问的详细信息,请参见文件选择器中的文件访问和权限

要求

最低支持客户端

Windows 8 [仅 Windows 应用商店应用程序]

最低支持服务器

Windows Server 2012 [仅 Windows 应用商店应用程序]

最低支持电话

Windows Phone 8 [未实现,请参见备注]

命名空间

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

元数据

Windows.winmd

另请参见

Windows.Storage.storageFolder.createFolderQuery methods
Windows.Storage.storageFolder.createFolderQueryWithOptions method
Windows.Storage.BulkAccess.folderInformation.createFolderQuery methods
Windows.Storage.BulkAccess.folderInformation.createFolderQueryWithOptions method

 

 

显示: