PickFileResult Klasse

Definition

Stellt das Ergebnis eines Dateiauswahlvorgangs dar. Dies ist eine einfache Klasse, die ein Zeichenfolgen-Attribut enthält, das den Dateipfad darstellt.

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
Vererbung
Object Platform::Object IInspectable PickFileResult
Attribute

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie die PickFileResult-Klasse verwendet wird, um den Dateipfad einer ausgewählten Datei abzurufen:

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
}

Hinweise

Ein PickFileResult-Objekt kann in Windows konvertiert werden. Storage.StorageFile-Objekt über GetFileFromPathAsync mithilfe der Datei Path.

Eigenschaften

Name Beschreibung
Path

Eine Zeichenfolge , die den Pfad der Datei enthält, die vom Benutzer im Dialogfeld "Dateiauswahl" ausgewählt wurde.

Gilt für:

Weitere Informationen