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/develop/files/index.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
@@ -41,7 +41,7 @@ If you're developing packaged WinUI apps, the WinRT storage APIs can be a powerf
41
41
|[Create, write, and read a file](/windows/uwp/files/quickstart-reading-and-writing-files)| Read and write a file using a [StorageFile](/uwp/api/Windows.Storage.StorageFile) object. |
42
42
|[Best practices for writing to files](/windows/uwp/files/best-practices-for-writing-to-files)| Learn best practices for using various file writing methods of the [FileIO](/uwp/api/windows.storage.fileio) and [PathIO](/uwp/api/windows.storage.pathio) classes. |
43
43
|[Get file properties](/windows/uwp/files/quickstart-getting-file-properties)| Get properties—top-level, basic, and extended—for a file represented by a [StorageFile](/uwp/api/Windows.Storage.StorageFile) object. |
44
-
|[Open files and folders with a picker](/windows/uwp/files/quickstart-using-file-and-folder-pickers)| Access files and folders by letting the user interact with a picker. You can use the [FolderPicker](/uwp/api/Windows.Storage.Pickers.FolderPicker) to gain access to a folder. |
44
+
|[Open files and folders with a picker](/windows/uwp/files/quickstart-using-file-and-folder-pickers)| Access files and folders by letting the user interact with a picker. You can use the [FolderPicker](/uwp/api/Windows.Storage.Pickers.FolderPicker) to gain access to a folder.<br/><br/>**NOTE:** In a desktop app (which includes WinUI 3 apps), you can use file and folder pickers from [Windows.Storage.Pickers](/uwp/api/windows.storage.pickers). However, if the desktop app requires elevation to run, you'll need a different approach because these APIs aren't designed to be used in an elevated app. For an example, see [FileSavePicker](/uwp/api/windows.storage.pickers.filesavepicker#in-a-desktop-app-that-requires-elevation).|
45
45
|[Save a file with a picker](/windows/uwp/files/quickstart-save-a-file-with-a-picker)| Use [FileSavePicker](/uwp/api/Windows.Storage.Pickers.FileSavePicker) to let users specify the name and location where they want your app to save a file. |
46
46
|[Accessing HomeGroup content](/windows/uwp/files/quickstart-accessing-homegroup-content)| Access content stored in the user's HomeGroup folder, including pictures, music, and videos. |
47
47
|[Determining availability of Microsoft OneDrive files](/windows/uwp/files/quickstart-determining-availability-of-microsoft-onedrive-files)| Determine if a Microsoft OneDrive file is available using the [StorageFile.IsAvailable](/uwp/api/windows.storage.storagefile.isavailable) property. |
Copy file name to clipboardExpand all lines: uwp/files/quickstart-using-file-and-folder-pickers.md
+27-21Lines changed: 27 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
ms.assetid: F87DBE2F-77DB-4573-8172-29E11ABEFD34
3
3
title: Open files and folders with a picker
4
4
description: Access files and folders by letting the user interact with a picker. You can use the FileOpenPicker and FileSavePicker classes to gain access to files, and the FolderPicker to gain access to a folder.
5
-
ms.date: 12/19/2018
5
+
ms.date: 02/08/2024
6
6
ms.topic: article
7
7
keywords: windows 10, uwp
8
8
ms.localizationpriority: medium
@@ -11,44 +11,44 @@ ms.localizationpriority: medium
Access files and folders by letting the user interact with a picker. You can use the [**FileOpenPicker**](/uwp/api/Windows.Storage.Pickers.FileOpenPicker) and [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker) classes to access files, and the [**FolderPicker**](/uwp/api/Windows.Storage.Pickers.FolderPicker) to access a folder.
19
19
20
20
> [!NOTE]
21
21
> For a complete sample, see the [File picker sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/FilePicker).
22
22
23
-
## Prerequisites
23
+
> [!NOTE]
24
+
> In a desktop app (which includes WinUI 3 apps), you can use file and folder pickers from [Windows.Storage.Pickers](/uwp/api/windows.storage.pickers). However, if the desktop app requires elevation to run, you'll need a different approach because these APIs aren't designed to be used in an elevated app. For an example, see [FileSavePicker](/uwp/api/windows.storage.pickers.filesavepicker#in-a-desktop-app-that-requires-elevation).
24
25
26
+
## Prerequisites
25
27
26
-
-**Understand async programming for Universal Windows Platform (UWP) apps**
28
+
-**Understand async programming for Universal Windows Platform (UWP) apps**
27
29
28
30
You can learn how to write asynchronous apps in C# or Visual Basic, see [Call asynchronous APIs in C# or Visual Basic](../threading-async/call-asynchronous-apis-in-csharp-or-visual-basic.md). To learn how to write asynchronous apps in C++, see [Asynchronous programming in C++](../threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps.md).
29
31
30
-
-**Access permissions to the location**
32
+
-**Access permissions to the location**
31
33
32
34
See [File access permissions](file-access-permissions.md).
33
35
34
36
## File picker UI
35
37
36
-
37
38
A file picker displays information to orient users and provide a consistent experience when opening or saving files.
38
39
39
40
That information includes:
40
41
41
-
-The current location
42
-
-The item or items that the user picked
43
-
-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).
42
+
- The current location
43
+
- The item or items that the user picked
44
+
- 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).
44
45
45
46
An email app might display a file picker for the user to pick attachments.
46
47
47
48

48
49
49
50
## How pickers work
50
51
51
-
52
52
With a picker your app can access, browse, and save files and folders on the user's system. Your app receives those picks as [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) and [**StorageFolder**](/uwp/api/Windows.Storage.StorageFolder) objects, which you can then operate on.
53
53
54
54
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: they are returned as [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) objects. 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. If you want your app to provide files, a save location, or file updates to other apps, see [Integrating with file picker contracts](/previous-versions/windows/apps/hh465192(v=win.10)).
@@ -59,7 +59,6 @@ For example, you might call the file picker in your app so that your user can op
Thisexamplecreatesarich, visualdisplayofpicturesinaconvenientlocationthattheusercanpickfrombysettingthreeproperties: [**ViewMode**](/uwp/api/windows.storage.pickers.fileopenpicker.viewmode), [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.fileopenpicker.suggestedstartlocation), and [**FileTypeFilter**](/uwp/api/windows.storage.pickers.fileopenpicker.filetypefilter).
101
100
102
-
-Setting [**ViewMode**](/uwp/api/windows.storage.pickers.fileopenpicker.viewmode) tothe [**PickerViewMode**](/uwp/api/Windows.Storage.Pickers.PickerViewMode) **Thumbnail**enumvalue creates a rich, visual display by using picture thumbnails to represent files in the file picker. Do this for picking visual files such as pictures or videos. Otherwise, use [**PickerViewMode.List**](/uwp/api/Windows.Storage.Pickers.PickerViewMode). A hypothetical email app with **Attach Picture or Video** and **Attach Document** features would set the **ViewMode** appropriate to the feature before showing the file picker.
101
+
-Setting [**ViewMode**](/uwp/api/windows.storage.pickers.fileopenpicker.viewmode) tothe [**PickerViewMode**](/uwp/api/Windows.Storage.Pickers.PickerViewMode) **Thumbnail**enumvalue creates a rich, visual display by using picture thumbnails to represent files in the file picker. Do this for picking visual files such as pictures or videos. Otherwise, use [**PickerViewMode.List**](/uwp/api/Windows.Storage.Pickers.PickerViewMode). A hypothetical email app with **Attach Picture or Video** and **Attach Document** features would set the **ViewMode** appropriate to the feature before showing the file picker.
103
102
104
-
- Setting [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.fileopenpicker.suggestedstartlocation) to Pictures using [**PickerLocationId.PicturesLibrary**](/uwp/api/Windows.Storage.Pickers.PickerLocationId) starts the user in a location where they're likely to find pictures. Set **SuggestedStartLocation** to a location appropriate for the type of file being picked, for example Music, Pictures, Videos, or Documents. From the start location, the user can navigate to other locations.
103
+
- Setting [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.fileopenpicker.suggestedstartlocation) to Pictures using [**PickerLocationId.PicturesLibrary**](/uwp/api/Windows.Storage.Pickers.PickerLocationId) starts the user in a location where they're likely to find pictures. Set **SuggestedStartLocation** to a location appropriate for the type of file being picked, for example Music, Pictures, Videos, or Documents. From the start location, the user can navigate to other locations.
105
104
106
-
- Using [**FileTypeFilter**](/uwp/api/windows.storage.pickers.fileopenpicker.filetypefilter) to specify file types keeps the user focused on picking files that are relevant. To replace previous file types in the **FileTypeFilter** with new entries, use [**ReplaceAll**](/uwp/api/windows.storage.pickers.fileextensionvector.replaceall) instead of [**Add**](/uwp/api/windows.storage.pickers.fileextensionvector.append).
105
+
- Using [**FileTypeFilter**](/uwp/api/windows.storage.pickers.fileopenpicker.filetypefilter) to specify file types keeps the user focused on picking files that are relevant. To replace previous file types in the **FileTypeFilter** with new entries, use [**ReplaceAll**](/uwp/api/windows.storage.pickers.fileextensionvector.replaceall) instead of [**Add**](/uwp/api/windows.storage.pickers.fileextensionvector.append).
107
106
108
-
2. **Show the FileOpenPicker**
107
+
2. **Show the FileOpenPicker**
109
108
110
109
- **To pick a single file**
111
110
@@ -145,7 +144,6 @@ Using a file picker involves creating and customizing a file picker object, and
> 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. You can learn more about using these lists in [How to track recently-used files and folders](how-to-track-recently-used-files-and-folders.md).
168
+
> 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. You can learn more about using these lists in [How to track recently-used files and folders](how-to-track-recently-used-files-and-folders.md).
0 commit comments