StorageFolder.CreateFolderQuery() | createFolderQuery() method

Applies to Windows only

Gets a query result object that contains the subfolders in the current folder.

Syntax


public:
StorageFolderQueryResult^ CreateFolderQuery()

Parameters

This method has no parameters.

Return value

Type: StorageFolderQueryResult

A query result object. Call the GetFoldersAsync method of the query result to get the subfolders in the current folder. This method returns a list of type IReadOnlyList<StorageFolder>. Each file or folder is represented by an item of type StorageFolder.

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.

You can also get a list of subfolders in the current folder asynchronously by calling one of the GetFoldersAsync methods.

To specify additional query options, call the CreateFolderQueryWithOptions method.

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

Examples

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

Before you run the following example, enable the Pictures Library capability in the app manifest file.


	// Get user's pictures folder
	StorageFolder^ picturesFolder = KnownFolders::PicturesLibrary;

	StorageFolderQueryResult^ itemsInFolder = picturesFolder->CreateFolderQuery();
	create_task(itemsInFolder->GetFoldersAsync()).then([=](IVectorView<StorageFolder^>^ itemsInFolder) {
		//Iterate over the results and print the list of files
		// 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

None supported

Namespace

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

Metadata

Windows.winmd

See also

StorageFolder
CreateFolderQuery(CommonFolderQuery)

 

 

Show:
© 2014 Microsoft