如何获取目录中LastWriteTime最老的文件?



如果我有一个通配符的完整路径,我怎么能得到最老的LastWriteTime文件?

$fullpath = "myFolder:foooBar*.txt"
$theOldestFile = # What to write to get among the 
                 #fooBar*.txt that has the max LastWriteTime?

像这样:

$fullpath = "myFolder:foooBar*.txt"
$theOldestFile = dir $fullpath | sort lastwritetime | select -First 1

最新更新