Пример #1
0
        /// <summary>
        /// After this method either the config file is present or the app is terminated
        /// </summary>
        /// <param name="create">Call with true only</param>
        public static bool createOrVerifyConfigFile(bool create = true)
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory + configFileName;

            if (!File.Exists(path))
            {
                //try to create a default config file
                string dlgResult = _msgBox.Show("Configuration file " + path + " was not found. Do you want to have a default config file be created?", "QIRX Configuration", "YesNo", "Question");
                if (dlgResult == "No")
                {
                    _msgBox.Show("No Configuration File present. Application cannot continue.", "QIRX Configuration",
                                 "OK", "Error");
                    Environment.Exit(-1);
                }
                if (create)
                {
                    if (!createConfigFile(path))
                    {
                        _msgBox.Show("Cannot create config file. Please check if directory is writeable. Application cannot continue.",
                                     "QIRX Config File Creator", "OK", "Error");
                        Environment.Exit(-1);
                    }

                    return(createOrVerifyConfigFile(false));
                }
                return(false);
            }
            ConfigFilePath = path;
            return(true);
        }