0

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.

5
Contributors
8
Replies
10
Views
8 Years
Discussion Span
Last Post by Weakegg
0

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

0

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.

0

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

0

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

0

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

0
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();
                }
            }
        }

Edited by Nick Evan: Removed TEX-tags. For Code use [CODE] tags

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.