时间戳为文件夹中的新JPG文件进行Cheking [英] Time Stamp Cheking for new JPG files in a folder
本文介绍了时间戳为文件夹中的新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 theSystem.IO.FileSystemWatcher
. Subscribe for itsCreated
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屋!
查看全文