C#递归遍历文件夹下的文件
/// <summary>
/// 递归搜索文件夹下的文件
/// </summary>
/// <param name="dir">文件夹路径</param>
private void GetAll(DirectoryInfo dir)
{
FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
if (Path.GetExtension(fi.Name) == ".xls")//遍历文件后缀为.xls的文件
{
FindWord(fi.FullName);
}
}
DirectoryInfo[] allDir = dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
GetAll(d);
}
}