Skip to content

Commit 7867ed9

Browse files
committed
Add desktop note to save picker quickstart page
1 parent ffe6494 commit 7867ed9

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

uwp/files/quickstart-save-a-file-with-a-picker.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ms.assetid: 8BDDE64A-77D2-4F9D-A1A0-E4C634BCD890
33
title: Save a file with a picker
44
description: Use FileSavePicker to let users specify the name and location where they want your app to save a file.
5-
ms.date: 12/19/2018
5+
ms.date: 02/08/2024
66
ms.topic: article
77
keywords: windows 10, uwp
88
ms.localizationpriority: medium
@@ -11,32 +11,32 @@ ms.localizationpriority: medium
1111

1212
**Important APIs**
1313

14-
- [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker)
15-
- [**StorageFile**](/uwp/api/Windows.Storage.StorageFile)
14+
- [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker)
15+
- [**StorageFile**](/uwp/api/Windows.Storage.StorageFile)
1616

1717
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.
1818

1919
> [!NOTE]
2020
> For a complete sample, see the [File picker sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/FilePicker).
2121
22-
 
22+
> [!NOTE]
23+
> 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).
2324
2425
## Prerequisites
2526

26-
27-
- **Understand async programming for Universal Windows Platform (UWP) apps**
27+
- **Understand async programming for Universal Windows Platform (UWP) apps**
2828

2929
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).
3030

31-
- **Access permissions to the location**
31+
- **Access permissions to the location**
3232

3333
See [File access permissions](file-access-permissions.md).
3434

3535
## FileSavePicker: step-by-step
3636

3737
Use a [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker) so that your users can specify the name, type, and location of a file to save. Create, customize, and show a file picker object, and then save data via the returned [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) object that represents the file picked.
3838

39-
1. **Create and customize the FileSavePicker**
39+
1. **Create and customize the FileSavePicker**
4040

4141
```cs
4242
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
@@ -48,21 +48,21 @@ Use a [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker) so t
4848
savePicker.SuggestedFileName = "New Document";
4949
```
5050

51-
Set properties on the file picker object that are relevant to your users and your app. This example sets three properties: [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedstartlocation), [**FileTypeChoices**](/uwp/api/windows.storage.pickers.filesavepicker.filetypechoices) and [**SuggestedFileName**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedfilename).
52-
 
53-
- Because our user is saving a document or text file, the sample sets [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedstartlocation) to the app's local folder by using [**LocalFolder**](/uwp/api/windows.storage.applicationdata.localfolder). Set [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.fileopenpicker.suggestedstartlocation) to a location appropriate for the type of file being saved, for example Music, Pictures, Videos, or Documents. From the start location, the user can navigate to other locations.
51+
Set properties on the file picker object that are relevant to your users and your app. This example sets three properties: [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedstartlocation), [**FileTypeChoices**](/uwp/api/windows.storage.pickers.filesavepicker.filetypechoices) and [**SuggestedFileName**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedfilename).
52+
53+
- Because our user is saving a document or text file, the sample sets [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedstartlocation) to the app's local folder by using [**LocalFolder**](/uwp/api/windows.storage.applicationdata.localfolder). Set [**SuggestedStartLocation**](/uwp/api/windows.storage.pickers.fileopenpicker.suggestedstartlocation) to a location appropriate for the type of file being saved, for example Music, Pictures, Videos, or Documents. From the start location, the user can navigate to other locations.
5454

55-
- Because we want to make sure our app can open the file after it is saved, we use [**FileTypeChoices**](/uwp/api/windows.storage.pickers.filesavepicker.filetypechoices) to specify file types that the sample supports (Microsoft Word documents and text files). Make sure all the file types that you specify are supported by your app. Users will be able to save their file as any of the file types you specify. They can also change the file type by selecting another of the file types that you specified. The first file type choice in the list will be selected by default: to control that, set the [**DefaultFileExtension**](/uwp/api/windows.storage.pickers.filesavepicker.defaultfileextension) property.
55+
- Because we want to make sure our app can open the file after it is saved, we use [**FileTypeChoices**](/uwp/api/windows.storage.pickers.filesavepicker.filetypechoices) to specify file types that the sample supports (Microsoft Word documents and text files). Make sure all the file types that you specify are supported by your app. Users will be able to save their file as any of the file types you specify. They can also change the file type by selecting another of the file types that you specified. The first file type choice in the list will be selected by default: to control that, set the [**DefaultFileExtension**](/uwp/api/windows.storage.pickers.filesavepicker.defaultfileextension) property.
5656

5757
> [!NOTE]
5858
> The file picker also uses the currently selected file type to filter which files it displays, so that only file types that match the selected files types are displayed to the user.
5959

60-
- To save the user some typing, the example sets a [**SuggestedFileName**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedfilename). Make your suggested file name relevant to the file being saved. For example, like Word, you can suggest the existing file name if there is one, or the first line of a document if the user is saving a file that does not yet have a name.
60+
- To save the user some typing, the example sets a [**SuggestedFileName**](/uwp/api/windows.storage.pickers.filesavepicker.suggestedfilename). Make your suggested file name relevant to the file being saved. For example, like Word, you can suggest the existing file name if there is one, or the first line of a document if the user is saving a file that does not yet have a name.
6161

62-
> [!NOTE]
63-
> [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker) objects display the file picker using the [**PickerViewMode.List**](/uwp/api/Windows.Storage.Pickers.PickerViewMode) view mode.
62+
> [!NOTE]
63+
> [**FileSavePicker**](/uwp/api/Windows.Storage.Pickers.FileSavePicker) objects display the file picker using the [**PickerViewMode.List**](/uwp/api/Windows.Storage.Pickers.PickerViewMode) view mode.
6464

65-
2. **Show the FileSavePicker and save to the picked file**
65+
2. **Show the FileSavePicker and save to the picked file**
6666

6767
Display the file picker by calling [**PickSaveFileAsync**](/uwp/api/windows.storage.pickers.filesavepicker.picksavefileasync). After the user specifies the name, file type, and location, and confirms to save the file, **PickSaveFileAsync** returns a [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) object that represents the saved file. You can capture and process this file now that you have read and write access to it.
6868

@@ -99,3 +99,13 @@ The example checks that the file is valid and writes its own file name into it.
9999

100100
> [!TIP]
101101
> You should always check the saved file to make sure it is valid before you perform any other processing. Then, you can save content to the file as appropriate for your app, and provide appropriate behavior if the picked file is not valid.
102+
103+
## See also
104+
105+
[Windows.Storage.Pickers](/uwp/api/windows.storage.pickers)
106+
107+
[Files, folders, and libraries](index.md)
108+
109+
[Integrating with file picker contracts](/previous-versions/windows/apps/hh465192(v=win.10))
110+
111+
[Creating, writing, and reading a file](quickstart-reading-and-writing-files.md)

0 commit comments

Comments
 (0)