如何使用.NET快速获取目录中最旧的文件? [英] how to get the oldest file in a directory fast using .NET?

查看:39
本文介绍了如何使用.NET快速获取目录中最旧的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录中有大约15至3万个文件.我只需要拉最老的一个.换句话说,首先创建的那个.除了将它们加载到集合中然后进行排序之外,是否有使用C#来执行此操作的快速方法?

I have a directory with around 15-30 thousand files. I need to just pull the oldest one. In other words the one that was created first. Is there a quick way to do this using C#, other than loading them into a collection then sorting?

推荐答案

简短的回答是. Windows文件系统不会按日期对文件进行索引,因此没有本机的方法可以做到这一点,更不用说.net了,无需枚举所有文件.

The short answer is no. Windows file systems don't index files by date so there is no native way to do this, let alone a .net way without enumerating all of them.

这篇关于如何使用.NET快速获取目录中最旧的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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