家用擦窗机论文:谁能给我段快速精简的 文件遍历源代码(C#)

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/11 04:32:08

遍历目录下所有文件的:
foreach(string fileName in System.IO.Directory.GetFiles("<dir-path>", "*.*"))
{
..............
}

遍历文件所有行的:
FileStream fs = new FileStream("<dir-path>", FileMode.Open, FileAccess.Read);
StreamReader streamReader = new StreamReader(fs, System.Text.Encoding.Default);
string data = streamReader.ReadLine();

while (data != null && data.Length > 0)
{
..............
description = streamReader.ReadLine();
}
fs.Close();