Skip to content

Commit 660fd74

Browse files
committed
Merged PR 22146: Add notes to picker ref docs in winrt about wasdk file and folder pickers
Add notes to picker ref docs in winrt about wasdk file and folder pickers. Recommend that users use the new pickers in WinUI and other desktop apps. ---- #### AI description (iteration 1) #### PR Classification Documentation update #### PR Summary This pull request updates the picker reference documentation by adding detailed notes and guidance on using the Windows App SDK APIs for file and folder pickers, particularly addressing elevated mode issues and WinUI usage. - **`filesavepicker.md`**: Enhanced the important note with emphasized formatting for the PickSaveFileAsync method, added a note for WinUI apps, and included extended explanation for handling elevated desktop apps using the Windows App SDK. - **`windows_storage_pickers.md`**: Updated the description and remarks to clarify the functionality of picker APIs, highlighting that the Windows SDK APIs do not work in elevated mode and introducing Microsoft.Windows.Storage.Pickers for this scenario; additionally, the "see also" section was revised to include the new API reference. - **`fileopenpicker.md` and `folderpicker.md`**: Added note blocks with links to the respective WinUI documentation pages for FileOpenPicker and FolderPicker to guide desktop app usage. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2 parents 38cccd6 + dae8782 commit 660fd74

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

windows.storage.pickers/fileopenpicker.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ In a desktop app, before using an instance of this class in a way that displays
1919

2020
To get started accessing files and folders file picker, see [Quickstart: Accessing files with File Pickers](/windows/uwp/files/quickstart-using-file-and-folder-pickers).
2121

22+
> [!NOTE]
23+
> To use a file open picker in a WinUI app (or other desktop app), see the [FileOpenPicker class](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker) documentation for the Windows App SDK.
24+
2225
For information about how to use this API outside of UWP apps, see [Call interop APIs from a .NET app](/windows/apps/desktop/modernize/winrt-com-interop-csharp).
2326

2427
### Version history

windows.storage.pickers/filesavepicker.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,26 @@ In a desktop app, before using an instance of this class in a way that displays
1818
## -remarks
1919

2020
> [!IMPORTANT]
21-
> You must use the [FileTypeChoices property](filesavepicker_filetypechoices.md) property to specify one or more file types before you call the PickSaveFileAsync method, or the picker will thrown an exception.
21+
> You must use the [FileTypeChoices property](filesavepicker_filetypechoices.md) property to specify one or more file types before you call the **PickSaveFileAsync** method, or the picker will thrown an exception.
2222
2323
To learn how to save files through the file picker, see [How to save files through file pickers](/windows/uwp/files/quickstart-save-a-file-with-a-picker).
2424

25+
> [!NOTE]
26+
> To use a file save picker in a WinUI app, see the [FileSavePicker class](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.filesavepicker) documentation for the Windows App SDK.
27+
2528
To get started accessing files and folders file picker, see [Files, folders, and libraries ](/windows/uwp/files/index).
2629

2730
> [!WARNING]
2831
> If you try to show the file picker while your app is snapped, the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped or by unsnapping it before you call the file picker. The following code examples and the [File picker sample](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FilePicker) show you how.
2932
3033
### In a desktop app that requires elevation
3134

32-
In a desktop app (which includes WinUI 3 apps), you can use **FileSavePicker** (and other types from **Windows.Storage.Pickers**). But if the desktop app requires elevation to run, then you'll need a different approach (that's because these APIs aren't designed to be used in an elevated app). The code snippet below illustrates how you can use the [C#/Win32 P/Invoke Source Generator](https://github.com/microsoft/CsWin32) (CsWin32) to call the Win32 picking APIs instead. To learn how to use CsWin32, follow that link for the documentation.
35+
> [!IMPORTANT]
36+
> The file and folder picker APIs (Windows.Storage.Pickers) in the Windows SDK don't work when apps run as administrator (elevated mode). To address this gap, the [Microsoft.Windows.Storage.Pickers](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers) APIs are added to the Windows App SDK and support file and folder selection in elevated mode. It's designed for desktop apps and uses a WindowId property to link the picker to its host window.
37+
>
38+
> If you must use the Windows.Storage.Pickers APIs in an elevated desktop app, you can follow example below.
39+
40+
You can use **FileSavePicker** (and other types from **Windows.Storage.Pickers**) in a desktop app. However, if the desktop app requires elevation to run, then you'll need a different approach (that's because these APIs aren't designed to be used in an elevated app). The code snippet below illustrates how you can use the [C#/Win32 P/Invoke Source Generator](https://github.com/microsoft/CsWin32) (CsWin32) to call the Win32 picking APIs instead. To learn how to use CsWin32, follow that link for the documentation.
3341

3442
```csharp
3543
// NativeMethods.txt

windows.storage.pickers/folderpicker.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ In a desktop app, before using an instance of this class in a way that displays
2020

2121
To get started accessing files and folders with a picker, see [Open files and folders with a picker](/windows/uwp/files/quickstart-using-file-and-folder-pickers).
2222

23+
> [!NOTE]
24+
> To use a folder picker in a WinUI 3 app (or other desktop app), see the [FolderPicker class](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.folderpicker) documentation for the Windows App SDK.
25+
2326
### Version history
2427

2528
| Windows version | SDK version | Value added |

windows.storage.pickers/windows_storage_pickers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
## -description
99

10-
Provides classes for creating and managing user interface (UI) elements that let the user browse files, choose files to open, and to choose the name, extension, and location when storing files.
10+
The **Windows.Storage.Pickers** namespace contains classes that create file and folder picker dialogs. Use these classes to let users browse, select files to open, and choose where to save files with specific names and extensions.
1111

1212
## -remarks
1313

14+
The file and folder picker APIs (Windows.Storage.Pickers) in the Windows SDK don't work when apps run as administrator (elevated mode). To address this gap, the [Microsoft.Windows.Storage.Pickers](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers) APIs are added to the Windows App SDK and support file and folder selection in elevated mode. They are designed for desktop apps and use a WindowId property to link the picker to its host window.
15+
1416
## -examples
1517

1618
> [!TIP]
@@ -23,4 +25,4 @@ Provides classes for creating and managing user interface (UI) elements that let
2325
2426
## -see-also
2527

26-
[HomeGroup sample (Windows 10)](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/HomeGroup), [File picker sample (Windows 10)](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FilePicker), [Basic face detection sample (Windows 10)](https://go.microsoft.com/fwlink/p/?LinkId=620512), [File picker contracts sample](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FilePickerContracts), [Blobs sample](https://github.com/microsoft/Windows-universal-samples/tree/main/archived/MsBlobBuilder)
28+
[HomeGroup sample (Windows 10)](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/HomeGroup), [File picker sample (Windows 10)](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FilePicker), [Basic face detection sample (Windows 10)](https://go.microsoft.com/fwlink/p/?LinkId=620512), [File picker contracts sample](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FilePickerContracts), [Blobs sample](https://github.com/microsoft/Windows-universal-samples/tree/main/archived/MsBlobBuilder), [Microsoft.Windows.Storage.Pickers](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers)

0 commit comments

Comments
 (0)