首先要确定你的文本文件的编码格式
StreamReader sr = new StreamReader(,,);string str = sr.ReadLine();
byte[] line = Encoding.GetEncoding("GB2312").GetBytes(str);
int length = line.Length;
int count = length/80;
int modCount = (int)SqlInt32.Mod(length,80); 
if (modCount != 0)
   count = count +1;
string[] aaa = new string[count];
int index = 0;
for (int i= 0;i<count;i++)
{
  aaa[i] = Encoding.getEncoding("GB2312").GetString(line,index,80);
  index = index + 80;
}
需要做什么其他操作就自己加

解决方案 »

  1.   

    string path = @"c:\temp\MyTest.txt";        try 
            {
                if (File.Exists(path)) 
                {
                    File.Delete(path);
                }            using (StreamWriter sw = new StreamWriter(path)) 
                {
                    sw.WriteLine("This");
                    sw.WriteLine("is some text");
                    sw.WriteLine("to test");
                    sw.WriteLine("Reading");
                }            using (StreamReader sr = new StreamReader(path)) 
                {
                    //This is an arbitrary size for this example.
                    char[] c = null;                while (sr.Peek() >= 0) 
                    {
                        c = new char[5];
                        sr.Read(c, 0, c.Length);
                        //The output will look odd, because
                        //only five characters are read at a time.
                        Console.WriteLine(c);
                    }
                }