C# 读写TXT文件遇到乱码问题

来源:互联网 发布:linux mysqldump 导入 编辑:程序博客网 时间:2024/06/06 07:22
            
最初是用encoding.default后来改为下面这个就好了
using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.IO;  using System.CodeDom;    namespace ConsoleApplication1  {      class Program      {          static void Main(string[] args)          {               FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);            StreamReader sr = new StreamReader(fs, Encoding.UTF8);
<span style="white-space:pre"></span>                 string s = fs.ReadLine();              string t = f.ReadLine();              while (s != null)              {                  Console.WriteLine(s);                  Console.WriteLine(t);                  s = fs.ReadLine();                  t = f.ReadLine();              }              fs.Close();              Console.ReadKey();          }      }  }  

0 0
原创粉丝点击