다음을 통해 공유


StorageFolder.DeleteAsync 메서드

정의

오버로드

DeleteAsync()

현재 폴더를 삭제합니다.

DeleteAsync(StorageDeleteOption)

현재 폴더를 삭제합니다. 이 메서드는 폴더를 영구적으로 삭제할지 여부도 지정합니다.

DeleteAsync()

현재 폴더를 삭제합니다.

public:
 virtual IAsyncAction ^ DeleteAsync() = DeleteAsync;
/// [Windows.Foundation.Metadata.Overload("DeleteAsyncOverloadDefaultOptions")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction DeleteAsync();
[Windows.Foundation.Metadata.Overload("DeleteAsyncOverloadDefaultOptions")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction DeleteAsync();
function deleteAsync()
Public Function DeleteAsync () As IAsyncAction

반환

이 메서드가 완료되면 개체 또는 값이 반환되지 않습니다.

구현

특성

예외

지정된 폴더를 삭제할 수 있는 권한이 없습니다.

예제

다음 예제에서는 DeleteAsync(StorageDeleteOption) 오버로드된 메서드를 호출하여 현재 폴더를 삭제하는 방법을 보여 줍니다. 이 예제에서는 파일을 영구적으로 삭제하는 옵션 의 값을 명시적으로 지정합니다.

using Windows.Storage;
using System.Threading.Tasks;
using System.Diagnostics; // For writing results to Output window.

// Get the app's local folder.
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

// Create a temporary folder in the current folder.
string folderName = "Test";
StorageFolder testFolder = await localFolder.CreateFolderAsync(folderName);

// Has the folder been created?
if(await localFolder.TryGetItemAsync(folderName) != null)
    Debug.WriteLine("Folder " + folderName + " exists.");
else
    Debug.WriteLine("Folder " + folderName + " does not exist.");

// Delete the folder permanently.
await testFolder.DeleteAsync(StorageDeleteOption.PermanentDelete);

// Has the folder been deleted?
if(await localFolder.TryGetItemAsync(folderName) != null)
    Debug.WriteLine("Folder " + folderName + " exists.");
else
    Debug.WriteLine("Folder " + folderName + " does not exist.");
IAsyncAction MainPage::ExampleCoroutineAsync()
{
    Windows::Storage::StorageFolder localFolder{ Windows::Storage::ApplicationData::Current().LocalFolder() };

    std::wstring folderName{ L"test" };

    Windows::Storage::StorageFolder newFolder{ co_await localFolder.CreateFolderAsync(folderName) };

    {
        // Check that the folder exists.
        Windows::Storage::IStorageItem newItem{ co_await localFolder.TryGetItemAsync(folderName) };
        std::wstringstream stringstream;
        stringstream << L"Folder: " << folderName.c_str();
        if (newItem)
        {
            stringstream << L" created" << std::endl;
        }
        else
        {
            stringstream << L" not found" << std::endl;
        }
        ::OutputDebugString(stringstream.str().c_str());
    }

    co_await newFolder.DeleteAsync(Windows::Storage::StorageDeleteOption::PermanentDelete);

    {
        // Check that the folder has been deleted.
        Windows::Storage::IStorageItem newItem{ co_await localFolder.TryGetItemAsync(folderName) };
        std::wstringstream stringstream;
        stringstream << L"Folder: " << folderName.c_str();
        if (newItem)
        {
            stringstream << L" not deleted" << std::endl;
        }
        else
        {
            stringstream << L" deleted" << std::endl;
        }
        ::OutputDebugString(stringstream.str().c_str());
    }
}
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());
});

설명

이 메서드는 암시적으로 StorageDeleteOption.Default 를 사용하여 항목이 영구적으로 삭제되는지 여부를 결정합니다.

추가 정보

적용 대상

DeleteAsync(StorageDeleteOption)

현재 폴더를 삭제합니다. 이 메서드는 폴더를 영구적으로 삭제할지 여부도 지정합니다.

public:
 virtual IAsyncAction ^ DeleteAsync(StorageDeleteOption option) = DeleteAsync;
/// [Windows.Foundation.Metadata.Overload("DeleteAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction DeleteAsync(StorageDeleteOption const& option);
[Windows.Foundation.Metadata.Overload("DeleteAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction DeleteAsync(StorageDeleteOption option);
function deleteAsync(option)
Public Function DeleteAsync (option As StorageDeleteOption) As IAsyncAction

매개 변수

option
StorageDeleteOption

폴더를 영구적으로 삭제할지 여부를 지정하는 열거형 값 중 하나입니다.

반환

이 메서드가 완료되면 개체 또는 값이 반환되지 않습니다.

구현

특성

예외

지정된 폴더를 삭제할 수 있는 권한이 없습니다.

추가 정보

적용 대상