2

How to set the DefaultExtension? In the following code, the first entry is, so gif displayed. DefaultExtension but png. What should I change to make it work?

Code snippet:

var savePicker = new FileSavePicker
{
     SuggestedStartLocation = PickerLocationId.PicturesLibrary,
     CommitButtonText = "Save",
     DefaultFileExtension = ".png",
     SettingsIdentifier = "fsp1",
     SuggestedFileName = "MyImage"
};
savePicker.FileTypeChoices.Add("Gif-Image", new List<string> { ".gif" });
savePicker.FileTypeChoices.Add("Jpeg-Image", new List<string> { ".jpg" });
savePicker.FileTypeChoices.Add("Png-Image", new List<string> { ".png" });
savePicker.FileTypeChoices.Add("Ico-File", new List<string> { ".ico" });
savePicker.FileTypeChoices.Add("Bmp-Image", new List<string> { ".bmp" });
StorageFile file = await savePicker.PickSaveFileAsync();
2
  • 1
    We are investigating this issue, we will come back to report as soon as possible.
    – Grace Feng
    Aug 15, 2016 at 7:01
  • I've report this issue, please check my answer.
    – Grace Feng
    Aug 18, 2016 at 3:12

1 Answer 1

0

Thank you for reporting this issue, we've confirmed that this is a logged issue. As currently implemented the DefaultFileExtension provides no meaningful use.

What should I change to make it work?

If you want to make the default file extension to be .png, here is a workaround:

Move your code savePicker.FileTypeChoices.Add("Png-Image", new List<string> { ".png" }); before savePicker.FileTypeChoices.Add("Gif-Image", new List<string> { ".gif" });. The first extension will be the default one in the list of FileTypeChoices.

2
  • Thanks for this information. The workaround but does not help me because the default extension is to be determined dynamically depending MimeType of image.
    – kendoo
    Aug 18, 2016 at 15:20
  • I am having the same requirement now, to @kendoo, even it's dynamically calculated, it can still be done (in an annoying way). However, I am disappointed to find out, after 3 years, this issue still exists!
    – sowen
    Mar 1, 2021 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.