导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

StorageFileQueryResult Class

提供对 storageFolder 对象所表示位置中文件查询结果的访问。 可以使用 storageFileQueryResult 来枚举该 storageFolder 位置中的文件。

语法


var storageFileQueryResult = storageFolder.createFileQuery();

特性

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

成员

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

事件

StorageFileQueryResult类 具有这些事件。

事件说明
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 StorageFileQueryResult 类 具有这些方法。 对于 C#、Visual Basic 和 C++,它还继承方法于Object 类.

方法说明
ApplyNewQueryOptions Modifies query results based on new QueryOptions.
FindStartIndexAsync 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 Retrieves the query options used to determine query results.
GetFilesAsync() Retrieves a list of all the files in the query result set.
GetFilesAsync(UInt32, UInt32) Retrieves a list of files in a specified range.
GetItemCountAsync Retrieves the number of files in the set of query results.
GetMatchingPropertiesWithRanges Gets matching file properties with corresponding text ranges.

 

属性

StorageFileQueryResult类 具有这些属性。

属性访问类型说明

Folder

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

 

备注

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

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

Windows Phone 8

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

示例

此示例演示如何从 storageFileQueryResult 对象中获取文件列表。



// 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
    });
});

query 变量获取检索符合查询标准的文件所使用的 storageFileQueryResult

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

要求

最低支持客户端

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

最低支持服务器

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

最低支持电话

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

命名空间

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

元数据

Windows.winmd

另请参见

Windows.Storage.storageFolder.createFileQuery methods
Windows.Storage.storageFolder.createFileQueryWithOptions method
Windows.Storage.BulkAccess.folderInformation.createFileQuery
Windows.Storage.BulkAccess.folderInformation.createFileQueryWithOptions

 

 

显示:
© 2014 Microsoft