語言

PickFolderResult 類別

定義

代表資料夾選擇操作的結果。 這是一個輕量級類別,包含一個代表資料夾路徑的字串屬性。

public ref class PickFolderResult sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.Storage.Pickers.StoragePickersContract, 65544)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PickFolderResult final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.Storage.Pickers.StoragePickersContract), 65544)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PickFolderResult
Public NotInheritable Class PickFolderResult
繼承
Object Platform::Object IInspectable PickFolderResult
屬性

範例

以下範例示範如何使用 PickFolderResult 類別取得所選資料夾的資料夾路徑:

using Microsoft.Windows.Storage.Pickers;

var picker = new FolderPicker();
var result = await picker.PickFolderAsync();
if (result != null)
{
    // Perform this conversion if you have business logic that uses StorageFolder
    var storageFolder = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(result.Path)
    // Continue your business logic with storageFolder
}
else
{
    // Add error handling logic here
}
#include <winrt/Microsoft.Windows.Storage.Pickers.h>
using namespace winrt::Microsoft::Windows::Storage::Pickers;

FolderPicker picker;
auto& result{ co_await openPicker.PickSingleFolderAsync() };
if (result)
{
    // Perform this conversion if you have business logic that uses StorageFolder
    auto& storageFolder{ co_await winrt::Windows::Storage::StorageFolder::GetFolderFromPathAsync(result.Path) }
    // Continue your business logic with storageFolder
}
else
{
    // Add error handling logic here
}

備註

PickFolderResult 物件可以轉換成 Windows。透過呼叫 Windows 來取得 Storage.StorageFolder 物件。Storage.StorageFolder.GetFolderFromPathAsync 與 Path 資料夾一起。

屬性

名稱 Description
Path

使用者在資料夾選擇操作中選擇的資料夾路徑。 這是資料夾在檔案系統中位置的字串表示。

適用於

另請參閱