Esempio n. 1
0
        private void deleteConfigButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete OptionsOracle configuration files?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                if (!UpdateControl.ResetConfiguration(UpdateControl.ExitAndRestartModeT.ExitAndRestart))
                {
                    string cnfg_dirc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\OptionsOracle";
                    statusTextBox.Text += "Conf: Deleting local configuration files...\r\n";

                    if (!Directory.Exists(cnfg_dirc))
                    {
                        statusTextBox.Text += "Conf: Error! Config directory '" + cnfg_dirc + "' does not exist.\r\n";
                        return;
                    }

                    string[] file_list = new string[] { @"config.xml", @"parser.xml", @"wizard.xml", @"plugin.xml" };

                    foreach (string cnfg_file in file_list)
                    {
                        if (File.Exists(cnfg_dirc + @"\" + cnfg_file))
                        {
                            try
                            {
                                File.Delete(cnfg_dirc + @"\" + cnfg_file);
                                statusTextBox.Text += "Conf: Config file '" + cnfg_file + "' was deleted.\r\n";
                            }
                            catch
                            {
                                statusTextBox.Text += "Conf: Error! Failed to delete config file '" + cnfg_file + "'.\r\n";
                            }
                        }
                        else
                        {
                            statusTextBox.Text += "Conf: Error! Config file '" + cnfg_file + "' does not exist.\r\n";
                        }
                    }

                    MessageBox.Show("Configuration files were removed, please restart OptionsOracle to create them.", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    statusTextBox.Text += "Conf: Config files were deleted successfully.\r\n";
                }
            }
        }