更新时间:2022-04-21 07:57:54
private List<String> DirSearch(string sDir)
{
List<String> files = new List<String>();
try
{
foreach (string f in Directory.GetFiles(sDir))
{
files.Add(f);
}
foreach (string d in Directory.GetDirectories(sDir))
{
files.AddRange(DirSearch(d));
}
}
catch (System.Exception excpt)
{
MessageBox.Show(excpt.Message);
}
return files;
}
如果您不想在内存中加载整个列表并避免阻塞,您可以查看以下答案
.
and if you don't want to load the entire list in memory and avoid blocking you may take a look at the following answer
.