时间戳为文件夹中的新JPG文件进行Cheking [英] Time Stamp Cheking for new JPG files in a folder

查看:95
本文介绍了时间戳为文件夹中的新JPG文件进行Cheking的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有问题。我有一个带有一些JPG图像的文件夹,文件夹经常更新新图片。我只有在图像是新的时才需要访问图像。我该如何执行此操作。 ??

Hi,
I have a problem with me.I have a folder with some JPG images and the folder updated frequently with new images.I need to access the images only if the images are new.How can i perform this operation. ??

推荐答案

尝试:

Try:
DirectoryInfo dir = new DirectoryInfo(@"D:\Temp");
FileInfo[] files = dir.GetFiles("*.jpg", SearchOption.AllDirectories);
DateTime newAfter = new DateTime(2012,1, 1);
FileInfo[] newFiles = files.Where(fi => fi.CreationTime > newAfter).ToArray();


您还可以使用 System.IO.FileSystemWatcher 。订阅其创建的事件。

如果文件通过慢速网络复制到您的文件夹,可能需要检查一段时间该文件已被访问。
You can also use the System.IO.FileSystemWatcher. Subscribe for its Created event.
If the file gets copied via a slow network to your folder, it may be necessary to check for a while if the file can already be accessed.


这篇关于时间戳为文件夹中的新JPG文件进行Cheking的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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