比方说,我已经排序的文件列表在资源管理器的名字,像这样:
Let's say I've sorted a list of files in Explorer by name, like so:
2009-06-02-4.0.9.txt 2009-06-02-4.0.10.txt 2009-06-02-4.0.11.txt 2009-06-02-4.0.12.txt
2009-06-02-4.0.9.txt 2009-06-02-4.0.10.txt 2009-06-02-4.0.11.txt 2009-06-02-4.0.12.txt
我有一个FileInfo的Comparer是按名称排序的FileInfo对象的数组:
I have a FileInfo Comparer that sorts an array of FileInfo objects by name:
class FileInfoComparer : IComparer<FileInfo> {
public int Compare(FileInfo x, FileInfo y) {
return string.Compare(x.FullName,
y.FullName,
StringComparison.OrdinalIgnoreCase);
}
}
排序相同的文件列表,上面用这个的Comparer收益率:
Sorting that same list of files from above using this Comparer yields:
2009-06-02-4.0.10.txt 2009-06-02-4.0.11.txt 2009-06-02-4.0.12.txt 2009-06-02-4.0.9.txt
2009-06-02-4.0.10.txt 2009-06-02-4.0.11.txt 2009-06-02-4.0.12.txt 2009-06-02-4.0.9.txt
这是个问题,因为顺序是非常重要的。
which is problematic, as the order is extremely important.
我会想象有办法模仿什么的Windows是做在C#code,但我还没有找到一种方法。任何帮助AP preciated!
I would imagine there's a way to mimic what Windows is doing in C# code, but I have yet to find a way. Any help is appreciated!
谢谢!
推荐答案
Windows资源管理器使用API名为:
Windows Explorer uses an API called:
StrCmpLogicalW
在一个合理的方式进行排序。
to perform the sort in a "logical" manner.
有人也实现一类在C#,以做这个给你。
Someone has also implemented a class in C# which will do this for you.
相关推荐
最新文章