Directory.GetFiles仅获取今天的文件 [英] Directory.GetFiles get today's files only

查看:248
本文介绍了Directory.GetFiles仅获取今天的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET Directory.GetFiles中有一个不错的功能,当我需要从目录中获取所有文件时,使用它很简单。

There is nice function in .NET Directory.GetFiles, it's simple to use it when I need to get all files from directory.

Directory.GetFiles("c:\\Files")

但是,如果有很多创建时间不同的文件,我怎么能(什么模式)只获取创建时间的文件呢?

But how (what pattern) can I use to get only files that created time have today if there are a lot of files with different created time?

谢谢!

推荐答案

尝试一下:

var todayFiles = Directory.GetFiles("path_to_directory")
                 .Where(x => new FileInfo(x).CreationTime.Date == DateTime.Today.Date);

这篇关于Directory.GetFiles仅获取今天的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆