Expand Minimize

StorageFolder class

Applies to Windows and Windows Phone

Manipulates folders and their contents, and provides information about them.

Syntax


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

Attributes

[Version(0x06020000)]

Members

The StorageFolder class has these types of members:

Methods

The StorageFolder class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
AreQueryOptionsSupported Determines whether the current folder supports the specified QueryOptions.
CreateFileAsync(String) Creates a new file with the specified name in the current folder.
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 with the specified name in the current folder.
CreateFolderAsync(String, CreationCollisionOption) Creates a new subfolder in 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 the file with the specified name from the current folder.
GetFilesAsync() Gets the files in the current folder.
GetFilesAsync(CommonFileQuery) Gets the files in the current folder and its subfolders (except when the value of query is CommonFileQuery.DefaultQuery). Files are sorted based on the specified value from the CommonFileQuery enumeration.
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 subfolders. Files are sorted based on the specified CommonFileQuery and are included in the range based on their indexes.
GetFolderAsync Gets the subfolder with the specified name from the current folder.
GetFolderFromPathAsync Gets the StorageFolder that has the specified absolute path in the file system.
GetFoldersAsync() Gets the subfolders in the current folder.
GetFoldersAsync(CommonFolderQuery) Gets a list of StorageFolder objects that represent groups of files in the current folder and its subfolders (except when the value of query is CommonFolderQuery.DefaultQuery). Files are grouped into folders based on the specified value from the CommonFolderQuery enumeration.
GetFoldersAsync(CommonFolderQuery, UInt32, UInt32) Gets an index-based range of StorageFolder objects that represent groups of files in the current folder and its subfolders. Files are grouped based on the specified CommonFolderQuery. Folders are included in the range based on their 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.

 

Properties

The StorageFolder class has these properties.

PropertyAccess typeDescription

Attributes

Read-onlyGets the attributes of the current folder.

DateCreated

Read-onlyGets the date and time that the current folder was created.

DisplayName

Read-onlyGets the user-friendly name of the current folder.

DisplayType

Read-onlyGets the user-friendly type of the folder or file group.

FolderRelativeId

Read-onlyGets 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

Read-onlyGets the name of the current folder.

Path

Read-onlyGets the full file-system path of the current folder, if the folder has a path.

Properties

Read-onlyGets an object that provides access to the content-related properties of the current folder.

Provider

Read-onlyGets the StorageProvider object that contains info about the service that stores the current folder.

 

Remarks

Typically, you access StorageFolder objects as the result of asynchronous method and/or function calls. For example, the static method GetFolderFromPathAsync returns a StorageFolder that represents the specified folder.

Additionally, whenever you call a file picker to let the user pick a folder the file picker will return the folder as a StorageFolder.

Examples

This example shows you how to call a file picker, using FolderPicker.PickSingleFolderAsync to capture and process a file that the users picks.


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
}

After PickSingleFileAsync completes, folder gets the picked file as a StorageFolder.

In the example, folderPicker contains a FolderPicker object. To learn more about using file pickers see FolderPicker and Quickstart: Accessing files with file pickers.

Additionally, folderToken gets an identifier that you can use to retrieve the folder from the FutureAccessList. To learn more about storing files and folders so you can access them again later, see FutureAccessList, MostRecentlyUsedList and How to track recently used files and folders.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

Capabilities

picturesLibrary
videosLibrary
musicLibrary
documentsLibrary

See also

StorageFile

 

 

Show:
© 2014 Microsoft