Expand Minimize

StorageFolder.GetFolderAsync | getFolderAsync method

Applies to Windows and Windows Phone

Gets the subfolder with the specified name from the current folder.

Syntax


storageFolder.getFolderAsync(name).done( /* Your success and error handlers */ );

Parameters

name

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The name (or path relative to the current folder) of the subfolder to get.

Return value

Type: IAsyncOperation<StorageFolder>

When this method completes successfully, it returns a StorageFolder that represents the specified subfolder.

Exceptions

ExceptionCondition
System.IO.FileNotFoundException

The specified folder does not exist. Check the value of name.

System.UnauthorizedAccessException

You don't have permission to access the specified folder.

System.ArgumentException

The path cannot be in Uri format (for example, /Assets). Check the value of name.

Examples

The following example shows how to get a subfolder from the current folder by calling the GetFolderAsync method. This example also shows how to get a subfolder from a subfolder of the current folder by providing a relative path.


// Get the app's local folder.
var localFolder = Windows.Storage.ApplicationData.current.localFolder;

// Create 2 levels of subfolders in the app's local folder.
var name1 = "Subfolder1";
var subFolder1Promise = localFolder.createFolderAsync(name1);
var subFolder2Promise = subFolder1Promise.then(function createFolder1Success(subFolder1) {

    var name2 = "Subfolder2";
    return subFolder1.createFolderAsync(name2);
});
var level1FolderPromise = subFolder1Promise.then(function createFolder1Success(subFolder1) {

    // Get the subfolder of the app's local folder.
    var level1FolderName = "Subfolder1";
    return localFolder.getFolderAsync(level1FolderName);
});
level1FolderPromise.done(function (level1Folder) {

});
var level2FolderPromise = subFolder2Promise.then(function createFolder2Success(subFolder2) {

    // Get the subfolder of the subfolder
    // by providing a relative path.
    var level2FolderName = "Subfolder1\\Subfolder2";
    return localFolder.getFolderAsync(level2FolderName);
});
level2FolderPromise.done(function getFolderSuccess(level2Folder) {

});

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

See also

StorageFolder
GetItemAsync

 

 

Show:
© 2014 Microsoft