首先要添加引用输入输出包
using System.IO;
StreamReader sr = File.OpenText(fileName);
string str = sr.ReadLine();
using System.IO;
StreamReader sr = File.OpenText(fileName);
string str = sr.ReadLine();
转载于:https://www.cnblogs.com/jiangkai007/archive/2009/09/07/1561902.html