获取路径中的最新目录 - 相对于目录名称 [英] Get latest directory in a path - with respect to the the name of directory

查看:68
本文介绍了获取路径中的最新目录 - 相对于目录名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求在路径中获取最后一个创建目录的名称,因为我在运行时使用的应用程序创建了两个目录,我只需要考虑其中一个,以后再显示。例如,应用程序创建
2文件夹,名称为:60000c和b3c143,我需要名称为"b3c143"的文件夹。我怎么能做到这一点?谢谢。

解决方案

通过LINQ:

 string olderDirectory = Directory.GetDirectories(pathToDirectory) .OrderBy(k => new DirectoryInfo(k).CreationTime).First(); 




Hi, i have a requirement to get the last created directory in a path with respect to its name, as an application i use created 2 directories during the runtime and i need to consider only one of them, which in order appears later. For e.g the app creates 2 folders with name: 60000c and b3c143 and i need the one with the name "b3c143". How can i acheive this? Thanks.

解决方案

By LINQ:

string olderDirectory = Directory.GetDirectories(pathToDirectory).OrderBy(k=>new DirectoryInfo(k).CreationTime).First();



这篇关于获取路径中的最新目录 - 相对于目录名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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