Rfd how to automatically add file extension name?

Hey guys I am using this library:

and in this code:

let files = FileDialog::new()
    .add_filter("text", &["txt", "rs"])
    .set_directory("/")
    .pick_file();

this will only limit file extension names with txt and rs,

however if I use the .save_file() instead, and I have this .add_filter("text", &["txt"]) then it would not then add the file extension name to it. Whilst it is possible for me to code this myself in my own code, is there a method I could use that would automatically add the file extension name if it does not exist?

The point of the filter is to prevent files without those extensions from being chosen, so you shouldn't really ever get a situation where the extension is missing?

I think you should use .set_file_name() and put an extension yourself. Filter is only make sense for picker. Moreover, the docs already stated:

1 Like