StorageFolder.GetFoldersAsync() | getFoldersAsync() method

Applies to Windows and Windows Phone

Gets the subfolders in the current folder.

Syntax


public:
IAsyncOperation<IVectorView>^ GetFoldersAsync()

Parameters

This method has no parameters.

Return value

Type: IAsyncOperation<IVectorView>

When this method completes successfully, it returns a list of the subfolders in the current folder. The list is of type IReadOnlyList<StorageFolder>. Each folder in the list is represented by a StorageFolder object.

Exceptions

ExceptionCondition
System.UnauthorizedAccessException

You don't have permission to access the contents of the current folder.

Remarks

This query is a shallow query that returns only subfolders in the current folder. For a list of methods that identifies shallow queries and deep queries, see the Remarks in the topic GetFoldersAsync.

To specify additional query options, call the CreateFolderQueryWithOptions method.

To get items that are files or folders, call the GetItemsAsync method.

Examples

The following example shows how to get the subfolders in the current folder by calling the GetFoldersAsync() method.


	// Get installation folder
	StorageFolder^ appFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

	// Get the subfolders in the current folder.
	create_task(appFolder->GetFoldersAsync()).then([=](IVectorView<StorageFolder^>^ itemsInFolder) {
		//Iterate over the results and print the list of folders
		// to the visual studio output window
		for (auto it = itemsInFolder->First(); it->HasCurrent; it->MoveNext())
		{
			StorageFolder^ file = it->Current;
			String^ output = file->Name + "\n";
			OutputDebugString(output->Begin());
		}
	});


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
GetFoldersAsync(CommonFolderQuery, UInt32, UInt32)
GetFoldersAsync(CommonFolderQuery)
GetItemsAsync

 

 

Show:
© 2014 Microsoft