0
txt文件有了這個代碼,我能夠讀取文件夾文件,但我想讀這是擺在子文件夾閱讀從子文件夾
防爆txt文件:
D:\Folder\NewFolder\Txt
D:\Folder\NewFolder1\Txt
D:\Folder\NewFolder2\Txt
我想讀txt文件「TXT」文件夾 「TXT」文件夾中是常見的所有子文件夾
Dictionary<string, string> found = new Dictionary<string, string>();
string line;
foreach (string filename in Directory.GetFiles(path.text))
{
using (StreamReader file = new StreamReader(filename))
{
while ((line = file.ReadLine()) != null)
{
if (line.Contains("Errors: 1"))
{
found.Add(line, filename);
label1.Text = "Failed \n" + filename;
label1.ForeColor = System.Drawing.Color.Red;
break;
}
}
}
}