我正在使用它来选择一个根文件夹并在将这些文件添加到我之前从每个目录中获取最新文件listbox
,我想知道是否有办法知道当前目录以便在我仍在搜索文件时更新我的 UI。
var rootDirFile = Directory
.EnumerateFiles(pathToSearch, "*.pcap", SearchOption.TopDirectoryOnly)
.OrderByDescending(f => File.GetCreationTime(f))
.Take(1);
var allNewestFilesOfEachFolder = Directory
.EnumerateDirectories(pathToSearch, "*.*", SearchOption.AllDirectories)
.Select(d => Directory.EnumerateFiles(d, "*.pcap")
.OrderByDescending(f => File.GetCreationTime(f))
.FirstOrDefault());
foreach (string tempFile in rootDirFile.Concat(allNewestFilesOfEachFolder))
{
//add the file
}