SaveFileDialog does not append file extension to file name
See original GitHub issueDescribe the bug
When saving a file with FilePickerSaveOptions
or SaveFileDialog
, the dialog doesn’t append the file extension to the user’s selected file name.
To Reproduce
var saveFileDialog = new SaveFileDialog
{
Title = "Where to export Library",
Filters = new()
{
new() { Name = "Excel Workbook (*.xlsx)", Extensions = new() { "xlsx" } }
}
};
var fileName = await saveFileDialog.ShowAsync(this);
//fileName has no file extension
Expected behavior
After the FilePickerSaveOptions
and SaveFileDialog
close, the user-selected file name should have the file extension of selected FileTypeChoices
.
Desktop (please complete the following information):
- OS: Windows
- Version 11.0.0-preview4
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
SaveFileDialog AddExtension doesn't work as expected
1 · I use the FilterIndex property to decide if I should store it as txt or xml file and not the extension...
Read more >SaveFileDialog does not append file extension in ...
If user does not provide file name extension, the return value should be appended with file extension using the extension provided in ...
Read more >SaveFileDialog Class (Microsoft.Win32)
Gets or sets a value indicating whether a file dialog automatically adds an extension to a file name if the user omits an...
Read more >[REQUEST] Save File Dialog does not include file- ...
The current save file dialog will not automaticaly include a file-extension in some cases. Steps to reproduce the bug:
Read more >How do I add filename, filter in saveitemdialog
I am using this code. SaveItemDialog tmpDestination = new SaveItemDialog() { Title = "ASCII Output file name", DefaultExt = "txt", Filter = "*....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem was with my patterns. I should have used the GLOB patterns like so:
Here’s an example using
StorageProvider
.If I save a file without manually typing the file extension,
selectedFile
will not have the file extension, and I have no idea whichFilePickerFileType
the user selected.