【发布时间】:2017-06-20 18:15:01
【问题描述】:
我对从文件夹中读取所有文件的顺序有疑问。
我的代码以错误的顺序读取文件 当我有文件时: 1.txt 2.txt 10.txt 20.txt 100.txt
我的代码读取文件查看文件的第一个字母: 1.txt 10.txt 100.txt 2.txt 20.txt
如何读取数字顺序的文件? 1.txt 2.txt 10.txt 20.txt 100.txt
我在下面使用代码:
Dim di As New DirectoryInfo(Path), fiArr As FileInfo() = di.GetFiles()
Dim strplik As FileInfo
For Each strplik In fiArr
'read strplik from file
next strplik
【问题讨论】:
-
那些不是数字,它们是经过测试的,所以
9.txt将“高于”1000.txt。您需要使用自然排序such as the one here 对结果进行排序另外请阅读How to Ask 并采取tour -
这是一个几乎相同的问题stackoverflow.com/q/12907499/5162073
-
那么有什么方法不对文件名进行排序吗?
-
@JakubM:不。