Ejemplo n.º 1
0
        /// <summary>
        /// 读取配置文件获取文件存储上下文
        /// </summary>
        /// <returns></returns>
        private FileStorageContext GetContext()
        {
            FileStorageContext      context = new FileStorageContext();
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

            fileMap.ExeConfigFilename = configPath;

            Configuration configuration = ConfigurationManager
                                          .OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            foreach (var key in configuration.AppSettings.Settings.AllKeys)
            {
                context.SetConfig(key, configuration.AppSettings.Settings[key].Value);
            }
            return(context);
        }