Fileコレクションの順序は?


てす  2012-08-17 10:42:25  No: 103337  IP: [192.*.*.*]

Dim Path 'ディレクトリパス
Dim Fso 'Scripting.FileSystemObject
Dim File 'Fileコレクション

Path = "\\○\○" '該当ディレクトリパス設定

Set Fso = CreateObject("Scripting.FileSystemObject")
Set File = Fso.GetFolder(Path).Files

Fileに格納される順番はどのような順番ですか?
File名順にならんでいるように感じますが、必ずFile名順で格納するようになっているのでしょうか。

編集 削除
魔界の仮面弁士  2012-08-17 14:16:54  No: 103338  IP: [192.*.*.*]

当方では、ファイル名順にならない場合も経験しています。

順序に保証されているわけではありませんが、恐らくは、FindFirstFile、FindNextFile APIのファイル検索順序と同じものであろうかと予想しています。

NTFSの場合はファイル名順、FATの場合には作成エントリー順といった感じで。
http://msdn.microsoft.com/en-us/library/aa364428%28VS.85%29.aspx

The order in which this function returns the file names is
dependent on the file system type. With the NTFS file system and CDFS file systems, the names are usually returned in alphabetical order. With FAT file systems, the names are usually returned in the order the files were written to the disk, which may or may not be in alphabetical order. However, as stated previously, these behaviors are not guaranteed.

編集 削除
てす  2012-08-17 17:35:33  No: 103339  IP: [192.*.*.*]

VBSにはソートがないと聞きます。
コレクションをファイル名順に並び替えるにはどうすれば良いのでしょうか。

編集 削除
魔界の仮面弁士  2012-08-17 22:31:42  No: 103340  IP: [192.*.*.*]

とりあえず、ADODB.Recordset の Sort プロパティで代用されては如何でしょう。

あるいは、JScript の Array.Sort を、wsc 経由や MSScriptControl 経由で
VBScript から利用するといった手もあります。

以下、VBScript のコードではありませんが参考までに。
http://hanatyan.sakura.ne.jp/patio/read.cgi?no=99
http://madia.world.coocan.jp/cgi-bin/VBBBS/wwwlng.cgi?print+201112/11120007.txt

編集 削除