Export (0) Print
Expand All

FileDialog.SupportMultiDottedExtensions Property

Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool SupportMultiDottedExtensions { get; set; }

Property Value

Type: System.Boolean
true if the dialog box supports multiple file name extensions; otherwise, false. The default is false.

Sometimes users must open and save files that use multiple file name extensions. For example, the application manifest files used by the ClickOnce deployment technology end in the complex file name extension ".exe.manifest". Setting this property to true enables you to set the Filter property to a multi-dotted extension.

If SupportMultiDottedExtensions is false, and you assign a multi-dotted extension to Filter, derived controls such as SaveFileDialog will only use the last extension in the string. For example, ".manifest" will be used instead of ".exe.manifest".

The following code example saves files with the extension ".data.txt". This code example requires that your application host a SaveFileDialog named saveFileDialog1 and a Button named button1.

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestSaveFileDialog
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            button1.Click += new EventHandler(button1_Click);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = "Data text files|.data.txt";
            saveFileDialog1.SupportMultiDottedExtensions = true;
            saveFileDialog1.FileOk += new CancelEventHandler(saveFileDialog1_FileOk);
            saveFileDialog1.ShowDialog();
        }

        void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                Stream s = saveFileDialog1.OpenFile();
                StreamWriter sw = new StreamWriter(s, Encoding.Unicode);
                sw.WriteLine("Hello, world!");
                sw.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not write file. Please try again later. Error message: " + ex.Message, "Error Writing File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
            }
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft