如何排序文件夹名称? [英] how to sort folder name ?

查看:80
本文介绍了如何排序文件夹名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友



i有开发窗口应用程序来处理文件夹。我想要对文件夹名称进行排序。我的文件夹名称如下所示:

 ctt2dzcz6 
ctt2dzcz6。 1
ctt2dzcz6。 2
ctt2dzcz6。 3
ctt2dzcz6。 4
ctt2dzcz6。 5
ctt2dzcz6。 6
ctt2dzcz6。 7
ctt2dzcz6。 8
ctt2dzcz6。 9
ctt2dzcz6。 10
ctt2dzcz6。 11



i试图将名称存储在数组中并对其进行排序。但它将如下所示

 ctt2dzcz6 
ctt2dzcz6 。 1
ctt2dzcz6。 10
ctt2 dzcz6。 11
ctt2dzcz6。 2
ctt2dzcz6。 3
ctt2dzcz6。 4
ctt2dzcz6。 5
ctt2dzcz6。 6
ctt2dzcz6。 7
ctt2dzcz6。< span class =code-digit> 8
ctt2dzcz6。 9
< ; / pre >





如何排序?

是否可以拆分和排序?

如何对文件名进行排序?

解决方案

这总是一个PITA - 字符串排序顺序与数字排序顺序不同,所以你不能按照你想要的方式直接排序,即使它只包含数字数字。

看看这个:用C#排序的数字字符串 [ ^ ] - 它为您排序文件名的错误部分,但您应该很容易更改!

Dear Friends

i have developing window application for processing folder.In that i want to sort folder name.my folder name is like the below:

ctt2dzcz6
ctt2dzcz6.1
ctt2dzcz6.2
ctt2dzcz6.3
ctt2dzcz6.4
ctt2dzcz6.5
ctt2dzcz6.6
ctt2dzcz6.7
ctt2dzcz6.8
ctt2dzcz6.9
ctt2dzcz6.10
ctt2dzcz6.11


i have tried to store the names in array and sort it.but it will be like the below

ctt2dzcz6
ctt2dzcz6.1
ctt2dzcz6.10
ctt2dzcz6.11
ctt2dzcz6.2
ctt2dzcz6.3
ctt2dzcz6.4
ctt2dzcz6.5
ctt2dzcz6.6
ctt2dzcz6.7
ctt2dzcz6.8
ctt2dzcz6.9
</pre>



How to sort it ?
is it possible to split and sort?
how to sort the file name?

解决方案

That is always a PITA - string sort order is different from numeric sort order, so you can''t directly sort by extension the way you want, even if it contains only numeric digits.
Have a look at this: Numeric String Sort in C#[^] - it sorts the "wrong" part of the file name for you, but it should be pretty easy for you to change!


这篇关于如何排序文件夹名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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