Search code examples
delphifiltertopendialogtsavedialog

Why don't the open and save dialogs show files matching the selected filter?


I want my open and save dialogs to display XML files. I have this definition:

// The save dialog
dlg := TSaveDialog.Create(nil);
dlg.Options := [ofOverwritePrompt];
dlg.Title := 'Seleccione la ubicación del archivo';
dlg.Filter := 'Xml | *.xml | Todo | *.*';
dlg.DefaultExt := 'xml';
dlg.Execute();
// The open dialog
dlg := TOpenDialog.Create(self);
dlg.Title := 'Seleccione la ubicación del archivo';
dlg.Filter := 'Xml | *.xml | Todo | *.*';
dlg.DefaultExt := 'xml';
dlg.Execute();

But it doesn't show XML files. To show any XML files in a path, I need to choose the "Todo" (*.*) filter. Why doesn't it show files when the XML filter is selected?


Solution

  • Remove the spaces around the extension. The dialog is trying to filter "*.xml " files, but there's none. Refer to the documentation for examples.