一聚教程网:一个值得你收藏的教程网站

热门教程

asp.net C#读取中文字符代码

时间:2022-06-25 05:03:09 编辑:袖梨 来源:一聚教程网

asp教程.net c#读取中文字符代码

private static void fnfileprocess()
{
streamreader reader = new streamreader(@"d:1500.txt", encoding.getencoding("gb2312"));
streamwriter writeren = new streamwriter(@"d:english.txt", false, encoding.utf8, 1024);
streamwriter writerch = new streamwriter(@"d:chinese.txt", false, encoding.utf8, 1024);
try
{
int i = 1;
for (string line = reader.readline(); line != null; line = reader.readline())
{
if (i % 2 == 1)
{
writeren.writeline(line);
}
else
{
writerch.writeline(line);
}
i++;
}
console.writeline(i + "tok");
}
catch (exception ex)
{
console.writeline(ex.tostring());
}
finally
{
//不清空缓冲区,得到的文件总是少几十行
writeren.flush();
writerch.flush();
}
}

热门栏目