CreateFolderAsync(String) | createFolderAsync(String) method
Collapse the table of content
Expand the table of content

StorageFolder.CreateFolderAsync(String) | createFolderAsync(String) method

Creates a new subfolder with the specified name in the current folder.

Syntax


public:
IAsyncOperation<StorageFolder>^ CreateFolderAsync(
  String^ desiredName
)

Parameters

desiredName

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

The name of the new subfolder to create in the current folder.

Return value

Type: IAsyncOperation<StorageFolder>

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

Exceptions

ExceptionCondition
System.IO.FileNotFoundException

The folder name contains invalid characters, or the format of the folder name is incorrect. Check the value of desiredName.

System.UnauthorizedAccessException

You don't have permission to create a subfolder in the current folder.

Remarks

This method uses the FailIfExists value from the CreationCollisionOption enumeration by default. That is, this method raises an exception if a subfolder with the same name already exists in the current folder. If you want to handle a folder name collision in a different way, call the CreateFolderAsync(String, CreationCollisionOption) method.

If you try to create a subfolder in a virtual folder like a library, or a folder that represents a container for a group of files (for example, the return value from some overloads of the GetFoldersAsync method), the CreateFolderAsync method may fail.

Examples

The following example shows how to create a new subfolder in the current folder by calling the CreateFolderAsync(String) method.


 //Get apps local folder
 StorageFolder^ localFolder = Windows::Storage::ApplicationData::Current->LocalFolder;

 // Create a new subfolder in the current folder
 // Raise an exception if it already exists
 String^ desiredName = "Subfolder";
 create_task(localFolder->CreateFolderAsync(desiredName)).then([](StorageFolder^ folder){
  //Do something with folder
 });


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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
CreateFolderAsync(String, CreationCollisionOption)

 

 

Show:
© 2016 Microsoft