Windows Dev Center

StorageFolder.DeleteAsync(StorageDeleteOption) | deleteAsync(StorageDeleteOption) method

Deletes the current folder. This method also specifies whether to delete the folder permanently.

Syntax


public:
IAsyncAction^ DeleteAsync(
  StorageDeleteOption option
)

Parameters

option

Type: StorageDeleteOption

One of the enumeration values that specifies whether to delete the folder permanently.

Return value

Type: IAsyncAction

No object or value is returned by this method when it completes.

Exceptions

ExceptionCondition
System.UnauthorizedAccessException

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

Examples

The following example shows how to delete the current folder by calling the DeleteAsync(StorageDeleteOption) method. This example explicitly specifies a value for option that deletes the file permanently.


	StorageFolder^ localFolder = ApplicationData::Current->LocalFolder;

	String^ folderName = "test";

	create_task(localFolder->CreateFolderAsync(folderName)).then([=](StorageFolder^ newFolder) -> task<IStorageItem^> {
		//Check the folder exists
		return create_task(localFolder->TryGetItemAsync(folderName));
	}).then([=](IStorageItem^ newFolder) -> task<void> {
		String^ output = "";
		if (newFolder == nullptr)
		{
			output = "Folder: " + folderName + " not found\n";
		}
		else
		{
			output = "Folder: " + folderName + " created\n";
		}
		OutputDebugString(output->Begin());
		return create_task(newFolder->DeleteAsync(StorageDeleteOption::PermanentDelete));
	}).then([=]() -> task<IStorageItem^>  {
		return create_task(localFolder->TryGetItemAsync(folderName));
	}).then([=](IStorageItem^ newFolder){
		String^ output = "";
		if (newFolder == nullptr)
		{
			output = "Folder: " + folderName + " deleted\n";
		}
		else
		{
			output = "Folder: " + folderName + " not deleted\n";
		}
		OutputDebugString(output->Begin());
	});


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

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
DeleteAsync

 

 

Show:
© 2015 Microsoft