今天看代码 发现有人使用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/ 
 

        

相关文章:

  • 2021-06-29
  • 2021-10-26
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-01-14
  • 2021-12-17
猜你喜欢
  • 2021-11-10
  • 2021-12-04
  • 2021-09-04
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案