How to use the SaveFileDialog filter

I created a filter with this code:

saveFileDialog1.FileName = "SimplifiedLog";
saveFileDialog1.Filter = "RichTextFormate | *.rtf |Text Files | *.txt |All Files| *.*";
saveFileDialog1.Title = "Save Simplified KL File";
saveFileDialog1.ShowDialog();

The problem is that every time I select a filter (other than the selected one), it adds the extension in the previous one. See the picture below:Unwanted filters

+4
source share
1 answer

You must remove the spaces:

saveFileDialog1.Filter = "RichTextFormate|*.rtf|Text Files|*.txt|All Files|*.*"; 

Spaces after and before |are evaluated as is, so you should not add them if it is not necessary.

+5
source

Source: https://habr.com/ru/post/1539159/


All Articles