FileSavePicker.FileTypeChoices FileSavePicker.FileTypeChoices FileSavePicker.FileTypeChoices FileSavePicker.FileTypeChoices FileSavePicker.FileTypeChoices Property

Definition

Gets the collection of valid file types that the user can choose to assign to a file.

public : IMap<Platform::String, IVector<Platform::String>> FileTypeChoices { get; }
IMap<winrt::hstring, IVector<winrt::hstring>> FileTypeChoices();
public IDictionary<string, IList<string>> FileTypeChoices { get; }
Public ReadOnly Property FileTypeChoices As IDictionary<string, IList<string>>
var iDictionary = fileSavePicker.fileTypeChoices;

Property Value

IDictionary<string, IList<string>> IDictionary<string, IList<string>> IDictionary<string, IList<string>>

A FilePickerFileTypesOrderedMap object that contains a collection of valid file types (extensions) that the user can use to save a file. Each element in this collection maps a display name to a corresponding collection of file name extensions. The key is a single string, the value is a list/vector of strings representing one or more extension choices.

Examples

The File picker sample demonstrates how to add file type choices with a display name.

FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "New Document";
// Create the picker object and set options
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
savePicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.fileTypeChoices.insert("Plain Text", [".txt"]);
// Default file name if the user does not type one in or select a file to replace
savePicker.suggestedFileName = "New Document";
auto plainTextExtensions{ winrt::single_threaded_vector<winrt::hstring>() };
plainTextExtensions.Append(L".txt");

savePicker.FileTypeChoices().Insert(L"Plain Text", plainTextExtensions);
savePicker.SuggestedFileName(L"New Document");

Remarks

Some apps do not need to understand a file format in order to process it - such as a cloud storage provider. Therefore, using the file wildcard character - "*" - is supported for the FileOpenPicker.FileTypeFilter collection. However, writing a file requires knowledge of its format. As a result, the wildcard is not supported for FileSavePicker.FileTypeChoices.

One display name as a classification of file types might have multiple file types that support it. For example, a display name of "HTML page" could be saved either with ".htm" or ".html" extension. That is why the value of each entry in a FilePickerFileTypesOrderedMap is an ordered list (vector) of strings, displayed in the UI in the order that you place the extensions in the vector.

See also