C#最简单的递归出所有的文件和文件

public List<FileInfo> FileInfoList { get; private set; } = new List<FileInfo>();
public List<DirectoryInfo> DirectoryInfoList { get; private set; } = new List<DirectoryInfo>();


public void FindFoldersAndFiles(string path)
{
foreach (string fileName in Directory.GetFiles(path))
{
FileInfoList.Add(new FileInfo(fileName));
}
foreach (string directory in Directory.GetDirectories(path))
{
DirectoryInfoList.Add(new DirectoryInfo(directory));
FindFoldersAndFiles(directory);
}
}

上一篇:go 解决no required module provides package xxx: go.mod file not found in current directory or any pare


下一篇:电脑快捷键以及常用DOS命令