Well the save file dialog, for some reason removes all file extensions that are input to it. No matter what i do or how i set the filename value, it always removes the extension which is incredibly annoying when i need to extension to stay as it is otherwise the file will save without any extension, does anybody know how to get rid of this problem? thanks.

Nevermind, i just used a folder browser dialog instead and took my filename from the end of the URL.

Have you try saveFileDialog.AddExtension property? It is indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension.

The extension added to a file name depends on the currently selected file filter.

Yes i did try that, and it did not effect the dialog in the way i wanted.

Please post your code, so that any one can find the solution.

As i said, nevermind because i just swaped using the savefile dialog with a folderbrowserdialog.

For those who find this thread as a result of a search, here's how you set the extensions for a SaveFileDialog.

// Create new SaveFileDialog object
SaveFileDialog DialogSave = new SaveFileDialog();
 
// Default file extension
DialogSave.DefaultExt = "txt";
 
// Available file extensions
DialogSave.Filter = "Text file (*.txt)|*.txt|XML file (*.xml)|*.xml|All files (*.*)|*.*";

Here's where I found the snippet above: SaveFileDialog example

private void mnuFileSave_Click(object sender, EventArgs e)
        {
            if (dlgFileSave.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (string strFile in dlgFileSave.FileNames)
                {
                    SingleDocument document = new SingleDocument();
                    document.rtbNotice.SaveFile(strFile, RichTextBoxStreamType.PlainText);
                    document.MdiParent = this;
                    document.Show();
                }
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.