PickFileResult Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents the result of a file picking operation. This is a lightweight class that contains a string attribute representing the file path.
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
- Inheritance
- Attributes
Examples
The following example demonstrates how to use the PickFileResult class to get the file path of a selected file:
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
}
Remarks
A PickFileResult object can be converted to Windows.Storage.StorageFile object via GetFileFromPathAsync using the file Path.
Properties
| Path |
A string containing the path of the file selected by the user in the file picker dialog. |