解决Nini.dll 不能读取中文

今天看代码 发现有人使用Nini库 到网上查阅原来是配置文件读取库

于是下了一个最新版本 操练一下

发现读取中文的时候是乱码,于是乎调试了一下午,终于找到如何让其兼容中文。 

打开Nini项目 找到Config下的IniConfigSource.cs

找到如下代码:

        public void Load (string filePath)
        {
            Load (new StreamReader (filePath);
            this.savePath = filePath;  }

改为:

1 public void Load (string filePath)
2 {
3     Load (new StreamReader (filePath,System.Text.Encoding.Default));
4     this.savePath = filePath;

5 } 

 即可解决中文问题,哈哈其实这是一个编码问题而已。

Nini 下载地址:http://nini.sourceforge.net/ 
 

        

原文地址:https://www.cnblogs.com/topcoder/p/2473950.html