c# - 如何以与 Windows 资源管理器中相同的顺序从目录中获取文件?

标签 c# .net

<分区>

Possible Duplicate:
Natural Sort Order in C#

如何按照 Windows 资源管理器中显示的顺序从目录中读取文件?

例如windows资源管理器列表:

file 1.txt
file 2.txt
file 3.txt
file 4.txt
file 5.txt
file 6.txt
file 7.txt
file 8.txt
file 9.txt
file 10.txt
file 11.txt
file 12.txt

当 Directory.GetFiles() 列出时:

file 1.txt
file 10.txt
file 11.txt
file 12.txt
file 2.txt
file 3.txt
file 4.txt
file 5.txt
file 6.txt
file 7.txt
file 8.txt
file 9.txt

[编辑]

在这里你可以找到另一个解决方案:http://www.codeproject.com/KB/recipes/csnsort.aspx?msg=3342284

最佳答案

那个特殊的订单是 new feature added in WinXP .使用 Directory.GetFiles() 加载集合后,最好的选择是在集合上重新实现相同的排序算法(请参阅上面的链接了解如何操作)。 .

关于c# - 如何以与 Windows 资源管理器中相同的顺序从目录中获取文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3150380/

相关文章:

c# - 使用 Configure 方法时如何在代码中设置 WCF 基地址

c# - 如何模拟异步文件流

c# - Protobuf-net 序列化/反序列化到/从字节数组

c# - 有没有办法检查代码是否在 TransactionScope 中执行?

c# - 数据库设置不正确,IList 上的值为空

c# - 为什么 Roslyn 中有这么多对象池的实现?

c# - 将参数添加到 Razor 中的表单

c# - ServiceStack服务OnUnsubscribe\OnSubscribe\OnConnect用户显示名称错误

.net - 上传到 EC2 实例上的 S3 TransferUtility.UploadAsync 时为 "The connection with the server was terminated abnormally"

c# - 将属性设置为虚拟时停止加载 Entity Framework