PickFileResult Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Représente le résultat d’une opération de sélection de fichiers. Il s’agit d’une classe légère qui contient un attribut de chaîne représentant le chemin d’accès au fichier.
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
- Héritage
- Attributs
Exemples
L’exemple suivant montre comment utiliser la classe PickFileResult pour obtenir le chemin d’accès d’un fichier sélectionné :
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
}
Remarques
Un objet PickFileResult peut être converti en Windows. Objet Storage.StorageFile via GetFileFromPathAsync à l’aide du chemin d’accès du fichier.
Propriétés
| Nom | Description |
|---|---|
| Path |
Chaîne contenant le chemin d’accès du fichier sélectionné par l’utilisateur dans la boîte de dialogue sélecteur de fichiers. |