PickFileResult クラス

定義

ファイルの選択操作の結果を表します。 これは、ファイル パスを表す 文字列 属性を含む軽量クラスです。

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

次の例では、 PickFileResult クラスを使用して、選択したファイルのファイル パスを取得する方法を示します。

using Microsoft.Windows.Storage.Pickers;

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

FileOpenPicker picker;
auto& result{ co_await openPicker.PickSingleFileAsync() };
if (result)
{
    // Perform this conversion if you have business logic that uses StorageFile
    auto& storageFile{ co_await winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(result.Path) }
    // Continue your business logic with storageFile
}
else
{
    // Add error handling logic here
}

注釈

PickFileResult オブジェクトは、Windowsに変換できますファイル パスを使用した GetFileFromPathAsync 経由の Storage.StorageFile オブジェクト。

プロパティ

名前 説明
Path

ファイル ピッカー ダイアログでユーザーが選択したファイルのパスを含む 文字列

適用対象

こちらもご覧ください