How to use filter of SaveFileDialog
Asked Answered
N

1

6

I have created 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 any filter (Other than the selected one) it adds extension in the previous one. See Picture below:Unwanted Filters

Noted answered 4/5, 2014 at 10:26 Comment(3)
I would remove the superfluous spaces.Stipendiary
how to remove superfluous spacesNoted
I put it in a short answer.Stipendiary
S
9

You should remove the spaces:

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

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

Stipendiary answered 4/5, 2014 at 10:34 Comment(2)
Ok so spaces causes all the problems Thanks for HelpNoted
I added spaces because it look clean and nicer without considering that it cause problemNoted

© 2022 - 2024 — McMap. All rights reserved.