简单文本文件处理

Posted chenqingwei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单文本文件处理相关的知识,希望对你有一定的参考价值。

 

 

int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成int(chfrom~chend)
int chend = Convert.ToInt32("9fff", 16);

using (FileStream fsFile = new FileStream(@"english.txt", FileMode.Open))
{
StreamReader srReader = new StreamReader(fsFile);

while (-1 != srReader.Peek())// or try "sr.Peek>=0"
{
string strLine = srReader.ReadLine();

string strEnglish = "";
string strChinese = "";
int code = 0;
for (int i = 5; i < strLine.Length; i++)
{
code = Char.ConvertToUtf32(strLine, i);
if (code >= chfrom && code <= chend)
{
strEnglish = strLine.Substring(0, i);
strChinese = strLine.Substring(i, strLine.Length - i);
break;
}
}
Console.WriteLine(strEnglish);

Console.ReadLine();
Console.WriteLine(strChinese);
Console.ReadLine();
}

}

以上是关于简单文本文件处理的主要内容,如果未能解决你的问题,请参考以下文章

python具体在文本处理上怎么用

[文件]Linux文本处理常用命令总结

从文本文件中读取第一行的 Windows 批处理命令

使用 python 生成器处理大型文本文件

练习题,使用多线程编写一个简单的文本处理工具

Windows 批处理文件 - 如果窗口标题包含文本,则 taskkill