private void OnButtonExportClick(object sender, EventArgs e)
        {
            ClearDetails();
            var folderBrowserDialog = new FolderBrowserDialog();
            var result = folderBrowserDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var settings = new AStyleSettings {
                CppCommandLine           = CppOptions,
                CsCommandLine            = CsOptions,
                CppFormatOnSave          = CppFormatOnSave,
                CsFormatOnSave           = CsFormatOnSave,
                CppIgnoredFileExtensions = CppIgnoredFileExtensions,
                Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
            };

            string filePath = String.Format("{0}\\AStyleExtension-{1}-{2}-{3}.cfg", folderBrowserDialog.SelectedPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            var serializer = new XmlSerializer(typeof(AStyleSettings));

            try {
                using (var writer = new StreamWriter(filePath)) {
                    serializer.Serialize(writer, settings);
                }

                textBoxDetails.Text = String.Format("Your settings were successfully exported to {0}.", filePath);
            } catch (Exception) {
                textBoxDetails.Text = String.Format("Failed to export settings to {0}.", filePath);
            }
        }
        private void OnButtonImportClick(object sender, EventArgs e)
        {
            ClearDetails();
            AStyleSettings settings = null;

            var openFileDialog = new OpenFileDialog {
                DefaultExt = ".cfg",
                Filter     = "AStyle Extension Settings (*.cfg)|*.cfg"
            };

            var result = openFileDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            using (var fs = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                var serializer = new XmlSerializer(typeof(AStyleSettings));
                try {
                    settings = (AStyleSettings)serializer.Deserialize(fs);
                } catch (Exception) {
                    textBoxDetails.Text = String.Format("Failed to import settings from {0}.", openFileDialog.FileName);
                }
            }

            if (settings == null)
            {
                return;
            }

            CppOptions = settings.CppCommandLine;
            checkBoxCppFormatOnSave.Checked = settings.CppFormatOnSave;
            CppIgnoredFileExtensions        = settings.CppIgnoredFileExtensions;

            if (IsCSarpEnabled)
            {
                CsOptions = settings.CsCommandLine;
                checkBoxCsFormatOnSave.Checked = settings.CsFormatOnSave;
            }


            textBoxDetails.Text = String.Format("Your settings were successfully imported from {0}.{1}Click OK to save the changes.", openFileDialog.FileName, Environment.NewLine);
        }
        private void OnButtonExportClick(object sender, EventArgs e) {
            ClearDetails();
            var folderBrowserDialog = new FolderBrowserDialog();
            var result = folderBrowserDialog.ShowDialog();

            if (result != DialogResult.OK) {
                return;
            }

            var settings = new AStyleSettings {
                CppCommandLine = CppOptions,
                CsCommandLine = CsOptions,
                CppFormatOnSave = CppFormatOnSave,
                CsFormatOnSave = CsFormatOnSave,
                Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
            };

            string filePath = String.Format("{0}\\AStyleExtension-{1}-{2}-{3}.cfg", folderBrowserDialog.SelectedPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            var serializer = new XmlSerializer(typeof(AStyleSettings));
            try {
                using (var writer = new StreamWriter(filePath)) {
                    serializer.Serialize(writer, settings);
                } 
  
                textBoxDetails.Text = String.Format("Your settings were successfully exported to {0}.", filePath);
            } catch (Exception) {
                textBoxDetails.Text = String.Format("Failed to export settings to {0}.", filePath);
            }
        }