Exemple #1
0
        /*************************************************************************************************************************/

        /// <summary>
        /// open directory with configuration file</summary>
        public string  GetGlobalConfigDirectory()
        {
            return(Os.Combine(
                       Os.GetApplicationsDirectory(),
                       this.configFileDirectory
                       ));
        }
Exemple #2
0
        /*************************************************************************************************************************/

        /// <summary>
        /// load global config file from portable file configuration or global file configuration
        /// </summary>
        /// <param name="parameters">reference to parameter object</param>
        public ProgramOptionsFile(ProgramOptions programOptions)
        {
            this.programOptions = programOptions;

            // use local config file
            this.optionsFilePath = Os.Combine(Os.GetCurrentApplicationDirectory(), this.configFileName);

            // use global config file if local version not exist
            if (!Os.FileExists(this.optionsFilePath))
            {
                this.optionsFilePath = Os.Combine(
                    this.GetGlobalConfigDirectory(),
                    this.configFileName
                    );
            }

            // open config file if exist
            if (Os.FileExists(this.optionsFilePath))
            {
                this.LoadConfigFile();
            }
            else
            {
                string globalConfigDirectory = Os.Combine(
                    Os.GetApplicationsDirectory(),
                    this.configFileDirectory
                    );

                // create global config directory if not exist
                if (!Os.DirectoryExists(globalConfigDirectory))
                {
                    Os.CreateDirectory(globalConfigDirectory);
                }

                // if config file dosn't exist create one with default values
                this.SaveConfigFile();
            }
        }