SaveFileDialog does not show any possible extensions, despite using the Filter option

I'm creating a C # application right now that saves data to a file when a button is clicked. The file name and location are user-defined, and I want the program to automatically add the .txt extension to the name, and also show only 1 possible extension in the "save files as" combobox. I have this code:

SaveFileDialog Dialog1 = new SaveFileDialog();
Dialog1.DefaultExt = "txt";
Dialog1.Filter = "Pliki tekstowe | *.txt";
Dialog1.AddExtension = true;

private void button1_Click(object sender, EventArgs e)
{
    if (Dialog1.ShowDialog() == DialogResult.OK)
    {
        System.IO.Stream fileStream = Dialog1.OpenFile();
        System.IO.StreamWriter sw = new System.IO.StreamWriter(fileStream);
        sw.WriteLine("Writing some text in the file.");
        sw.WriteLine("Some other line.");
        sw.Flush();
        sw.Close();
    }
    this.Close();
}

, , , .txt , . , - , , , , ".txt" , , . ?

+3
2

- . :

Dialog1.Filter = "Pliki tekstowe|*.txt";

.

 *.txt ( *.txt) - , , .

+3

:

http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx

:

"txt files (*.txt)|*.txt|All files (*.*)|*.*"  

(*.txt) ( Yuck). - , :) , . ,

+1

All Articles