Example #1
0
        /// <summary>
        /// 读取配置文件,返回一个 Dictionary,键值都是字符串
        /// </summary>
        /// <param name="path">配置文件的路径(相对路径,相对于项目的根目录)</param>
        /// <param name="separator">键和值之间的分隔符</param>
        /// <returns>返回一个 Dictionary</returns>
        public static Dictionary <String, String> Read(String absPath, char separator)
        {
            if (strUtil.IsNullOrEmpty(absPath))
            {
                throw new IOException("config path is empty");
            }

            cfgHelper cfg = new cfgHelper();

            try {
                cfg.Content = file.Read(absPath);
            }
            catch (IOException) {
                cfg.Content = "";
            }

            return(cfg.toDic(separator));
        }