Skip to content

Commit 0c112ab

Browse files
Merge pull request #5927 from MicrosoftDocs/main
Auto Publish – main to live - 2025-10-29 05:00 UTC
2 parents 36eb898 + f9ac4bc commit 0c112ab

45 files changed

Lines changed: 349 additions & 262 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9589,6 +9589,11 @@
95899589
"source_path": "hub/apps/design/globalizing/use-mat.md",
95909590
"redirect_url": "/windows/apps/design/globalizing/mat-announcements",
95919591
"redirect_document_id": false
9592+
},
9593+
{
9594+
"source_path": "hub/powertoys/dsc-configure.md",
9595+
"redirect_url": "/windows/powertoys/dsc-configure/overview",
9596+
"redirect_document_id": false
95929597
}
95939598
]
95949599
}

hub/apps/design/input/drag-and-drop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ See [**ListViewBase.CanReorderItems**](/uwp/api/windows.ui.xaml.controls.listvie
102102

103103
The [UIElement](/uwp/api/windows.ui.xaml.uielement) class does most of the work of implementing drag-and-drop for you. But if you want, you can implement your own version by using the APIs below.
104104

105-
| Functionality | WinAppSDK API </br> Microsoft.UI.Input.DragDrop namespace | UWP API <br/> Windows.Applicationmodel.DataTransfer.DragDrop.Core namespace |
105+
| Functionality | Windows App SDK</br> Microsoft.UI.Input.DragDrop namespace | UWP<br/> Windows.Applicationmodel.DataTransfer.DragDrop.Core namespace |
106106
| --- | --- | --- |
107107
| DragPrimitive | [DragOperation](/windows/windows-app-sdk/api/winrt/microsoft.ui.input.dragdrop.dragoperation) | [CoreDragOperation](/uwp/api/windows.applicationmodel.datatransfer.dragdrop.core.coredragoperation) |
108108
| Create a data package | [DataPackage](/uwp/api/windows.applicationmodel.datatransfer.datapackage) | same |

hub/apps/develop/files/using-file-folder-pickers.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Open Files and Folders With Windows App SDK Pickers
2+
title: Open files and folders with Windows App SDK pickers
33
description: Learn how to use Windows App SDK file and folder pickers in your WinUI app. Implement FileOpenPicker and FolderPicker classes with step-by-step code examples and best practices.
4-
ms.date: 09/10/2025
4+
ms.date: 10/28/2025
55
ms.topic: how-to
66
keywords: windows 11, winui, windows app sdk
77
# Customer intent: As a Windows app developer, I want to use the file picker APIs in Windows App SDK to allow users to open files and folders in my WinUI app, so that they can specify the name and location of the file or folder.
@@ -17,7 +17,7 @@ To learn about using a picker to save files, see [Save a file with a Windows App
1717

1818
## Important APIs
1919

20-
The following APIs are used in this topic:
20+
This article uses the following APIs:
2121

2222
- [FileOpenPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker)
2323
- [FolderPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker)
@@ -30,24 +30,24 @@ A file picker displays information to orient users and provide a consistent expe
3030
That information includes:
3131

3232
- The current location
33-
- The item or items that the user picked
33+
- The item or items that the user picks
3434
- A tree of locations that the user can browse to. These locations include file system locations—such as the Music or Downloads folder—as well as apps that implement the file picker contract (such as Camera, Photos, and Microsoft OneDrive).
3535

36-
You may have an app that lets users open or save files. When the user initiates that action, your app calls the file picker, which displays the file picker UI:
36+
You might have an app that lets users open or save files. When the user initiates that action, your app calls the file picker, which displays the file picker UI:
3737

38-
![A screenshot of an open file picker with a filter selected to show .txt, .pdf, .doc, and .docx files.](images/picker-open-file.png)
38+
:::image type="content" source="images/picker-open-file.png" alt-text="Screenshot of an open file picker with a filter selected to show .txt, .pdf, .doc, and .docx files.":::
3939

4040
## How pickers work with your app
4141

42-
With a picker your app can access, browse, and save files and folders on the user's system. Your app receives those picks as lightweight [PickFileResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfileresult) and [PickFolderResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfolderresult) objects, which provide the path to the selected file or folder.
42+
With a picker, your app can access, browse, and save files and folders on the user's system. Your app receives those picks as lightweight [PickFileResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfileresult) and [PickFolderResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfolderresult) objects, which provide the path to the selected file or folder.
4343

4444
The picker uses a single, unified interface to let the user pick files and folders from the file system or from other apps. Files picked from other apps are like files from the file system. In general, your app can operate on them in the same ways as other objects. Other apps make files available by participating in file picker contracts.
4545

46-
For example, you might call the file picker in your app so that your user can open a file. This makes your app the calling app. The file picker interacts with the system and/or other apps to let the user navigate and pick the file. When your user chooses a file, the file picker returns that file's path to your app.
46+
For example, you might call the file picker in your app so that your user can open a file. This action makes your app the calling app. The file picker interacts with the system and other apps to let the user navigate and pick the file. When your user chooses a file, the file picker returns that file's path to your app.
4747

4848
## Pick a file to open example
4949

50-
The following code shows how to use the [FileOpenPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker) class to let the user pick a single file, such as a photo. The code sets properties on the picker to customize its appearance and behavior, and then shows the picker to the user using the [PickSingleFileAsync](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker.picksinglefileasync) method. If the user picks a file, the app reads the file's content and stores it in a variable.
50+
The following code shows how to use the [FileOpenPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker) class to let the user pick a single file, such as a photo. The code sets properties on the picker to customize its appearance and behavior, and then shows the picker to the user by using the [PickSingleFileAsync](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker.picksinglefileasync) method. If the user picks a file, the app reads the file's content and stores it in a variable.
5151

5252
```csharp
5353
using Microsoft.Windows.Storage.Pickers;
@@ -87,9 +87,10 @@ This is the same example in C++:
8787
#include <winrt/Microsoft.Windows.Storage.Pickers.h>
8888
#include <fstream>
8989
#include <string>
90+
9091
using namespace winrt::Microsoft::Windows::Storage::Pickers;
9192

92-
FileOpenPicker openPicker(AppWindow().Id());
93+
FileOpenPicker openPicker(this->AppWindow().Id());
9394

9495
// (Optional) Specify the initial location for the picker.
9596
// If the specified location doesn't exist on the user's machine, it falls back to the DocumentsLibrary.
@@ -106,7 +107,7 @@ openPicker.FileTypeFilter().ReplaceAll({ L".txt", L".pdf", L".doc", L".docx" });
106107
// (Optional) specify the view mode of the picker dialog. If not specified, defaults to List.
107108
openPicker.ViewMode(PickerViewMode::List);
108109

109-
auto& result{ co_await openPicker.PickSingleFileAsync() };
110+
auto result{ co_await openPicker.PickSingleFileAsync() };
110111
if (result)
111112
{
112113
std::ifstream fileReader(result.Path().c_str());
@@ -143,16 +144,17 @@ else
143144
}
144145
```
145146

146-
To perform the same operation in C++, you can use the following code:
147+
To perform the same operation in C++, use the following code:
147148

148149
```cpp
149150
#include <winrt/Microsoft.Windows.Storage.Pickers.h>
150151
#include <fstream>
151152
#include <string>
153+
152154
using namespace winrt::Microsoft::Windows::Storage::Pickers;
153155

154-
FileOpenPicker openPicker(AppWindow().Id());
155-
auto& results{ co_await openPicker.PickMultipleFilesAsync() };
156+
FileOpenPicker openPicker(this->AppWindow().Id());
157+
auto results{ co_await openPicker.PickMultipleFilesAsync() };
156158
if (results.Size() > 0)
157159
{
158160
for (auto const& result : results)
@@ -170,7 +172,7 @@ else
170172

171173
## Pick a folder example
172174

173-
To pick a folder using the [FolderPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker) class, you can use the following code. This code creates a folder picker, shows it to the user using the [PickSingleFolderAsync](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker.picksinglefolderasync) method, and retrieves the selected folder's path in a [PickFolderResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfolderresult) object. If the user picks a folder, the app retrieves the folder's path and stores it in a variable which can be used later.
175+
To pick a folder by using the [FolderPicker](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker) class, use the following code. This code creates a folder picker, shows it to the user by using the [PickSingleFolderAsync](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker.picksinglefolderasync) method, and retrieves the selected folder's path in a [PickFolderResult](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.pickfolderresult) object. If the user picks a folder, the app retrieves the folder's path and stores it in a variable for later use.
174176

175177
```csharp
176178
using Microsoft.Windows.Storage.Pickers;
@@ -202,13 +204,14 @@ else
202204
}
203205
```
204206

205-
To perform the same operation in C++, you can use the following code:
207+
To perform the same operation in C++, use the following code:
206208

207209
```cpp
208210
#include <winrt/Microsoft.Windows.Storage.Pickers.h>
211+
209212
using namespace winrt::Microsoft::Windows::Storage::Pickers;
210213

211-
FolderPicker folderPicker(AppWindow().Id());
214+
FolderPicker folderPicker(this->AppWindow().Id());
212215

213216
// (Optional) Specify the initial location for the picker.
214217
// If the specified location doesn't exist on the user's machine, it falls back to the DocumentsLibrary.
@@ -222,7 +225,7 @@ folderPicker.CommitButtonText(L"Select Folder");
222225
// (Optional) specify the view mode of the picker dialog. If not specified, default to List.
223226
folderPicker.ViewMode(PickerViewMode::List);
224227

225-
auto& result{ co_await folderPicker.PickSingleFolderAsync() };
228+
auto result{ co_await folderPicker.PickSingleFolderAsync() };
226229
if (result)
227230
{
228231
auto path{ result.Path() };
@@ -234,11 +237,11 @@ else
234237
```
235238

236239
> [!TIP]
237-
> Whenever your app accesses a file or folder through a picker, you can add it to your app's [FutureAccessList](/uwp/api/windows.storage.accesscache.storageapplicationpermissions.futureaccesslist) or [MostRecentlyUsedList](/uwp/api/windows.storage.accesscache.storageapplicationpermissions.mostrecentlyusedlist) to keep track of it using the Windows Runtime (WinRT) APIs. You can learn more about using these lists in [How to track recently-used files and folders](/windows/uwp/files/how-to-track-recently-used-files-and-folders).
240+
> Whenever your app accesses a file or folder through a picker, add it to your app's [FutureAccessList](/uwp/api/windows.storage.accesscache.storageapplicationpermissions.futureaccesslist) or [MostRecentlyUsedList](/uwp/api/windows.storage.accesscache.storageapplicationpermissions.mostrecentlyusedlist) to keep track of it by using the Windows Runtime (WinRT) APIs. For more information, see [How to track recently-used files and folders](/windows/uwp/files/how-to-track-recently-used-files-and-folders).
238241
239242
The folder picker UI looks like this:
240243

241-
![A screenshot of a folder picker viewing the C drive.](images/picker-folder.png)
244+
:::image type="content" source="images/picker-folder.png" alt-text="Screenshot of a folder picker viewing the C drive.":::
242245

243246
## Related content
244247

0 commit comments

Comments
 (0)