You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/apps/design/input/drag-and-drop.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ See [**ListViewBase.CanReorderItems**](/uwp/api/windows.ui.xaml.controls.listvie
102
102
103
103
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.
104
104
105
-
| Functionality |WinAppSDK API </br> Microsoft.UI.Input.DragDrop namespace | UWP API <br/> Windows.Applicationmodel.DataTransfer.DragDrop.Core namespace |
Copy file name to clipboardExpand all lines: hub/apps/develop/files/using-file-folder-pickers.md
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Open Files and Folders With Windows App SDK Pickers
2
+
title: Open files and folders with Windows App SDK pickers
3
3
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
5
5
ms.topic: how-to
6
6
keywords: windows 11, winui, windows app sdk
7
7
# 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
@@ -30,24 +30,24 @@ A file picker displays information to orient users and provide a consistent expe
30
30
That information includes:
31
31
32
32
- The current location
33
-
- The item or items that the user picked
33
+
- The item or items that the user picks
34
34
- 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).
35
35
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:
37
37
38
-

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.":::
39
39
40
40
## How pickers work with your app
41
41
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.
43
43
44
44
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.
45
45
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.
47
47
48
48
## Pick a file to open example
49
49
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.
51
51
52
52
```csharp
53
53
usingMicrosoft.Windows.Storage.Pickers;
@@ -87,9 +87,10 @@ This is the same example in C++:
auto results{ co_await openPicker.PickMultipleFilesAsync() };
156
158
if (results.Size() > 0)
157
159
{
158
160
for (auto const& result : results)
@@ -170,7 +172,7 @@ else
170
172
171
173
## Pick a folder example
172
174
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.
174
176
175
177
```csharp
176
178
usingMicrosoft.Windows.Storage.Pickers;
@@ -202,13 +204,14 @@ else
202
204
}
203
205
```
204
206
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:
auto result{ co_await folderPicker.PickSingleFolderAsync() };
226
229
if (result)
227
230
{
228
231
auto path{ result.Path() };
@@ -234,11 +237,11 @@ else
234
237
```
235
238
236
239
> [!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).
238
241
239
242
The folder picker UI looks like this:
240
243
241
-

244
+
:::image type="content" source="images/picker-folder.png" alt-text="Screenshot of a folder picker viewing the C drive.":::
0 commit comments