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)
{
StreamReader fs = new StreamReader("c:\\xin.txt",Encoding.GetEncoding("gb2312"));
StreamReader f = File.OpenText("C:\\xin.txt");
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();
}
}
}
上面程序中对同一个文件的两种打开方式中,第一个方式不会出现乱码,而第二个会出现乱码。
C#中读取txt文件中的中文时出现乱码问题
最新推荐文章于 2025-03-29 05:00:05 发布