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);
}
}