以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  用 FileSys.GetFiles 得到的文件名集合能否自动按一定规则排序?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=55692)

--  作者:jerzhh
--  发布时间:2014/8/21 14:05:00
--  用 FileSys.GetFiles 得到的文件名集合能否自动按一定规则排序?

用 FileSys.GetFiles 得到的文件名集合能否自动按一定规则排序?

 

比方说按文件名排序,或按扩展名排序存放在集合中。


--  作者:有点甜
--  发布时间:2014/8/21 14:17:00
--  
 无法排序,获取以后,你遍历重新排列再放在集合里面。
--  作者:Bin
--  发布时间:2014/8/21 14:26:00
--  
Dim ls() As String = System.IO.Directory.GetFiles("d:\\")
Array.Sort(ls)
For Each File As String In ls
    Output.Show(File)
Next

--  作者:lsy
--  发布时间:2014/8/21 15:23:00
--  
以下是引用Bin在2014-8-21 14:26:00的发言:
Dim ls() As String = System.IO.Directory.GetFiles("d:\\")
Array.Sort(ls)
For Each File As String In ls
    Output.Show(File)
Next

新方法,好方法。


--  作者:jerzhh
--  发布时间:2014/8/21 15:31:00
--  
以下是引用Bin在2014-8-21 14:26:00的发言:
Dim ls() As String = System.IO.Directory.GetFiles("d:\\")
Array.Sort(ls)
For Each File As String In ls
    Output.Show(File)
Next

 

谢谢!

 

再请教 Array.Sort 的降序用法


--  作者:有点甜
--  发布时间:2014/8/21 15:36:00
--  
Dim ls() As String = System.IO.Directory.GetFiles("d:\\")
Array.Sort(ls)
Array.Reverse(ls)
For Each File As String In ls
    Output.Show(File)
Next

--  作者:lsy
--  发布时间:2014/8/21 15:38:00
--  
Dim ls() As String = System.IO.Directory.GetFiles("C:\\Documents and Settings\\Administrator\\桌面\\CaseStudy")
Array.Sort(ls)
Array.Reverse(ls)
For Each File As String In ls
    Output.Show(File)
Next

--  作者:jerzhh
--  发布时间:2014/8/21 16:40:00
--  
以下是引用有点甜在2014-8-21 15:36:00的发言:
Dim ls() As String = System.IO.Directory.GetFiles("d:\\")
Array.Sort(ls)
Array.Reverse(ls)
For Each File As String In ls
    Output.Show(File)
Next

 

非常感谢。

 

那么请问集合是否有类似Array的共享成员?

 

比如说:

 

Dim Products As List(Of String)
Products = DataTables("产品").GetValues("产品名称")

List.Sort(Products)
List.Reverse(Products)

For Each Product As String In Products
    Output.Show(Product)

Next

 

这样可以吗?
 
还有字典Dictionary呢?

--  作者:有点甜
--  发布时间:2014/8/21 16:44:00
--  

不可以。字典和List没有。如果要用,你可以用toArray以后,再排序。


--  作者:pcxjxjhkw
--  发布时间:2014/12/11 16:44:00
--  
http://http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=61388&page=1&star=1