📜  asp.net 获取目录中的最新文件 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:08.209000             🧑  作者: Mango

代码示例1
var directory = new DirectoryInfo("C:\\MyDirectory");
var myFile = (from f in directory.GetFiles()
             orderby f.LastWriteTime descending
             select f).First();

// or...
var myFile = directory.GetFiles()
             .OrderByDescending(f => f.LastWriteTime)
             .First();