I have used the SaveItemDialog with 2 filters.
Whenever I type a name for the file I want to save it never puts the appropriate suffix for the file type I want to save as.
I cannot seem to find anything in the instance of the SaveItemDialog to see what the current filter selected is as there is nothing showing a property to this effect.
Can someone help me understand how I can get the right file suffix on save?
var jsonFilter = BrowseProjectFilter.GetFilter("esri_browseDialogFilters_json_file");
var csvFilter = BrowseProjectFilter.GetFilter("esri_browseDialogFilters_browseFiles");
csvFilter.FileExtension = "csv";
csvFilter.Name = "CSV files (*.csv)|*.csv";
csvFilter.BrowsingFilesMode = true;
BrowseProjectFilter compositeFilter = new BrowseProjectFilter();
compositeFilter.AddFilter(jsonFilter);
compositeFilter.AddFilter(csvFilter);
SaveItemDialog saveDialog = new SaveItemDialog()
{
Title = "Save",
BrowseFilter = compositeFilter,
OverwritePrompt = true
};
bool? result = saveDialog.ShowDialog();
if (result == true)
{
//Get the selected file path
string filePath = saveDialog.FilePath;
//File path is always missing file suffix which is specified in the filter
}
Solved! Go to Solution.
As specified here:
"The value returned from the FilePath property is the full path to the file and its file name. The path is determined based on the location currently being viewed in the Browse dialog, which is extracted from the breadcrumb control. The file name includes the file extension that was specified in the Name text box or was defined as the default file extension for the dialog box."
It is not useful, but by design.
As specified here:
"The value returned from the FilePath property is the full path to the file and its file name. The path is determined based on the location currently being viewed in the Browse dialog, which is extracted from the breadcrumb control. The file name includes the file extension that was specified in the Name text box or was defined as the default file extension for the dialog box."
It is not useful, but by design.
So ESRI's implementation does not follow standard Windows behaviour? I really don't like it. The fact that you have to remember to type in the file extension. However, there is nothing I can do about it. I wish ESRI would change this to be more standard behaviour that we are used to.