FileStream fs2 = new FileStream(filePath + str2[4], FileMode.OpenOrCreate, FileAccess.ReadWrite);
            byte[] bb2 = new byte[2];
            UTF8Encoding date2 = new UTF8Encoding(true);
            while (fs2.Read(bb2, 0, bb2.Length) > 0)
            {
                txtPinlun.Text += date2.GetString(bb2);
            }
            fs2.Close();
读取txt文档里的内容 但是读不了中文 显示出来时方框谁有的话给几段代码 
读取txt文档的内容 要能读中文的
将字符串写入指定的txt文档的 这个txt内已有文字 要将新的插入到最后 不能覆盖原来的文档

解决方案 »

  1.   

    utf-8的中文不编码后不是3个字节,最好是读出所有的数据,然后用Encoding.GetString(byte[])方法,或者直接用System.IO.File.ReadAllText(path, Encoding.UTF8)读取整个字符串
      

  2.   

    string text=System.IO.File.ReadAllText(filePath + str2[4], Encoding.UTF8);
    string text=System.IO.File.ReadAllText(filePath + str2[4], Encoding.GetEncoding("GBK"));
    具体看你是哪种编码
      

  3.   

    字符集编码问题
    FileStream   fs   =   new   FileStream("",   FileMode.Open);   
      byte[]   bytes   =   new   byte[(int)fs.Length];   
      fs.Read(bytes,   0,   bytes.Length);   
      fs.Close();   
      string  s=System.Text.Encoding.GetEncoding("gb2312").GetString(bytes);   FileStream fs = new FileStream("",FileMode.OpenOrCreate,FileAccess.Write); 
    byte[] bytes   =Encoding.GetEncoding("gb2312").GetBytes(“”); 
    fs.Write(bytes   , 0);