PickFileResult クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ファイルの選択操作の結果を表します。 これは、ファイル パスを表す 文字列 属性を含む軽量クラスです。
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
- 継承
- 属性
例
次の例では、 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 |
ファイル ピッカー ダイアログでユーザーが選択したファイルのパスを含む 文字列 。 |