获取文件夹下最新文件 (转)
private void button1_Click(object sender, EventArgs e) { string[] res = GetLatestFiles(@"D:\dir\dir1", 5); } string[] GetLatestFiles(string Path, int count) { var query = (from f in Directory.GetFiles(Path) let fi = new FileInfo(f) orderby fi.CreationTime descending select fi.FullName).Take(count); return query.ToArray(); }