string pathFile="你的文件路径";//
private string OpenFileTxt(string path)
{
string txtContent="";
using(FileStream fs = new FileStream(path,FileMode.Open))
{
using(StreamReader sr = new StreamReader(fs,Encoding.UTF8))
{
while(sr.Peek()>0)//如果下一行还有数据
{
txtContent+=sr.ReadLine();
}
}
}
return txtContent;
}
温馨提示:答案为网友推荐,仅供参考