public static List<string> ReadList(string path, System.Text.Encoding encode)
{
List<string> result = new List<string>();
string s = "";
using (StreamReader sr = new StreamReader(path, encode))
{
while ((s = sr.ReadLine()) != null)
{
result.Add(s);
}
}
return result;
}
一行一行读取TXT数据并返回List
最新推荐文章于 2022-10-11 21:34:24 发布
本文介绍了一个实用的C#方法,该方法可以将指定路径的文件内容逐行读取为字符串列表。此方法利用了StreamReader组件,并允许指定文件编码。
2万+

被折叠的 条评论
为什么被折叠?



