从指定文件地址读取文件到一个string中,并解决中文乱码问题:
using System.IO; StreamReader reader = new StreamReader("D:/Resource/Taobao.txt",System.Text.Encoding.Default); String str; StringBuilder sb=new StringBuilder(); while ((str = reader.ReadLine()) != null) { sb.Append(str); } String result = sb.ToString();