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内已有文字 要将新的插入到最后 不能覆盖原来的文档
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内已有文字 要将新的插入到最后 不能覆盖原来的文档
string text=System.IO.File.ReadAllText(filePath + str2[4], Encoding.GetEncoding("GBK"));
具体看你是哪种编码
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);