Skip to main content
StorageFolder Class

操作文件夹及其内容,并提供有关它们的信息。

语法


var storageFolder = Windows.Storage.StorageFolder;

public sealed class StorageFolder : IStorageFolder,
    IStorageItem,
    IStorageFolderQueryOperations,
    IStorageItemProperties,
    IStorageItemProperties2,
    IStorageItem2,
    IStorageFolder2,
    IStorageItemPropertiesWithProvider

Public NotInheritable Class StorageFolder
    Implements IStorageFolder, _
    IStorageItem, _
    IStorageFolderQueryOperations, _
    IStorageItemProperties, _
    IStorageItemProperties2, _
    IStorageItem2, _
    IStorageFolder2, _
    IStorageItemPropertiesWithProvider

public ref class StorageFolder sealed : IStorageFolder,
    IStorageItem,
    IStorageFolderQueryOperations,
    IStorageItemProperties,
    IStorageItemProperties2,
    IStorageItem2,
    IStorageFolder2,
    IStorageItemPropertiesWithProvider

特性

[ Version(0x06020000)]

成员

StorageFolder类 具有以下类型的成员:

方法

The StorageFolder 类 具有以下方法。 使用 C#、Visual Basic 和 C++,它还可以继承以下内容中的方法 Object 类.

方法描述
AreQueryOptionsSupported Determines whether the current folder supports the specified QueryOptions.
CreateFileAsync(String) Creates a new file in the folder or file group.
CreateFileAsync(String, CreationCollisionOption) Creates a new file in the current folder, and specifies what to do if a file with the same name already exists in the current folder.
CreateFileQuery() Creates a query result object to filter and enumerate top-level files in the current folder.
CreateFileQuery(CommonFileQuery) Creates a query result object to filter and enumerate all the files in the current folder and its subfolders. Files are filtered and sorted based on the specified CommonFileQuery.
CreateFileQueryWithOptions Creates a query result object to filter and enumerate the files in the current folder and its subfolders. Files are included in the query result and sorted based on the specified QueryOptions.
CreateFolderAsync(String) Creates a new subfolder inside the current folder.
CreateFolderAsync(String, CreationCollisionOption) Creates a new sub-folder inside the current folder, and specifies what to do if a folder with the same name already exists in the current folder.
CreateFolderQuery() Creates a query result object to filter and enumerate top-level sub-folders of the current folder.
CreateFolderQuery(CommonFolderQuery) Creates a query result object to enumerate files in the current folder by grouping them into StorageFolder objects. Files are filtered and grouped based on the specified CommonFolderQuery.
CreateFolderQueryWithOptions Creates a query result object to filter and enumerate files in the current folder by grouping them into sub-folders. Files are included in the query result and grouped into sub-folders based on the specified QueryOptions.
CreateItemQuery Creates a query result object to filter and enumerate top-level items (files and sub-folders) in the current folder.
CreateItemQueryWithOptions Creates a query result object to filter and enumerate top-level items (files and sub-folders) in the current folder. Items are included in the query result and sorted based on the specified QueryOptions.
DeleteAsync() Deletes the current folder or file group.
DeleteAsync(StorageDeleteOption) Deletes the current folder or file group, optionally deleting it permanently.
GetBasicPropertiesAsync Gets the basic properties of the current folder or file group.
GetFileAsync Gets a single file from the current folder using the specified file name.
GetFilesAsync() Gets the top-level files in the current folder.
GetFilesAsync(CommonFileQuery) Gets a list of all files in the current folder and its sub-folders. Files are filtered and sorted based on the specified CommonFileQuery.
GetFilesAsync(CommonFileQuery, UInt32, UInt32) Gets an index-based range of files from the list of all files in the current the current folder and its sub-folders. Files are filtered and sorted based on the specified CommonFileQuery and are included in the range based on the resulting indexes.
GetFolderAsync Gets a single sub-folder from the current folder using the specified folder name.
GetFolderFromPathAsync Gets a StorageFolder that represents the folder at the specified file-system path.
GetFoldersAsync() Gets a list of the top-level sub-folders of the current folder.
GetFoldersAsync(CommonFolderQuery) Gets a list of StorageFolder objects that represent groups of files in the current folder. Files are filtered and grouped based on the specified CommonFolderQuery.
GetFoldersAsync(CommonFolderQuery, UInt32, UInt32) Gets an index-based range of StorageFolder objects that represent groups of files in the current folder. Files are filtered and grouped based on the specified CommonFolderQuery and are included in the range based on the resulting indexes.
GetIndexedStateAsync Gets the indexed state of the current folder.
GetItemAsync Gets a single file or sub-folder from the current folder using the name of the item.
GetItemsAsync() Gets a list of top-level files and sub-folders inside the current folder.
GetItemsAsync(UInt32, UInt32) Gets an index-based range from a list of all the files and sub-folders inside the current folder. Items in the range based on the resulting indexes.
GetParentAsync Gets the parent folder of the current folder.
GetScaledImageAsThumbnailAsync(ThumbnailMode) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail.
GetScaledImageAsThumbnailAsync(ThumbnailMode, UInt32) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail and the requested size.
GetScaledImageAsThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) Gets a scaled image as a thumbnail, determined by the purpose of the thumbnail, the requested size, and the specified options
GetThumbnailAsync(ThumbnailMode) Gets an adjusted thumbnail image for the current folder, determined by the specified purpose of the thumbnail.
GetThumbnailAsync(ThumbnailMode, UInt32) Gets an adjusted thumbnail image for the current folder, determined by the specified purpose of the thumbnail and the requested size.
GetThumbnailAsync(ThumbnailMode, UInt32, ThumbnailOptions) Gets an adjusted thumbnail image for the current folder, determined by the specified purpose of the thumbnail, the requested size, and the specified options.
IsCommonFileQuerySupported Indicates whether the current folder supports the specified CommonFileQuery.
IsCommonFolderQuerySupported Indicates whether the current folder supports the specified CommonFolderQuery.
IsEqual Indicates whether the current folder is equal to the specified folder.
IsOfType Indicates whether the current StorageFolder matches the specified StorageItemTypes value.
RenameAsync(String) Renames the current folder.
RenameAsync(String, NameCollisionOption) Renames the current folder and specifies what to do if a folder with the same name already exists.
TryGetItemAsync Try to get a single file or sub-folder from the current folder by using the name of the item.

 

属性

StorageFolder类 具有以下属性。

属性访问类型描述

Attributes

只读Gets the attributes of the current folder.

DateCreated

只读Gets the date and time that the current folder was created.

DisplayName

只读Gets the user-friendly name of the current folder.

DisplayType

只读Gets the user-friendly type of the folder or file group.

FolderRelativeId

只读Gets an identifier for the current folder. This ID is unique for the query result or StorageFolder that contains the current folder or file group, and can be used to distinguish between items that have the same name.

Name

只读Gets the name of the current folder.

Path

只读Gets the full file-system path of the current folder, if the folder has a path.

Properties

只读Gets an object that provides access to the content-related properties of the current folder.

Provider

只读Gets the StorageProvider object that contains info about the service that stores the current folder.

 

备注

通常,可以访问 StorageFolder 对象作为异步方法和/否函数调用的结果。例如,静态方法 GetFolderFromPathAsync 返回表示指定文件夹的 StorageFolder

此外,无论何时您调用文件选择器以让用户选择一个文件夹,文件选择器都会将文件夹作为 StorageFolder 返回。

示例

此示例演示如何调用文件选择器,使用 FolderPicker.PickSingleFolderAsync 来捕获并处理用户选择的文件。


StorageFile folder = await folderPicker.PickSingleFolderAsync();
// Process picked folder
if (folder != null)
{
    // Store folder for future access
    folderToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(folder);
}
else
{
    // The user didn't pick a folder
}

folderPicker.pickSingleFolderAsync().then(function (folder) {
   if (folder) {
       // Process picked folder

       // Store folder for future access
       var folderToken = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.add(folder);
   } else {
       // The user didn't pick a folder
   }
});

PickSingleFileAsync 完成后,folder 将选择的文件获取为 StorageFolder

在此示例中,folderPicker 包含 FolderPicker 对象。若要了解有关使用文件选择器查看 FolderPicker 快速入门的更多消息:使用文件选择器访问文件

此外,folderToken 会获取您可以用于从 FutureAccessList 检索文件夹的标识符。要了解关于存储文件和文件夹以便您可以稍后继续访问的详细信息,请参见 FutureAccessList MostRecentlyUsedList 如何跟踪最近使用的文件和文件夹

要求

最低受支持的客户端

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

最低受支持的服务器

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

最低受支持的电话

Windows Phone 8

命名空间

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

元数据

Windows.winmd

Capabilities

picturesLibrary
videosLibrary
musicLibrary
documentsLibrary

另请参阅

StorageFile

 

 

Microsoft 正在进行一项网上调查,以了解您对 网站的意见。如果您选择参加,我们将会在您离开 网站时向您显示该网上调查。

是否要参加?