一個文件夾中所有 File 對象的集合。
[JScript]
下面這個例子說明了如何獲得一個 Files 集合以及如何使用 Enumerator 對象和 for 語句來遍歷該集合:
[JScript]
function ShowFolderFileList(folderspec)
{
var fso, f, f1, fc, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.files
);
s = "";
for (; !fc.atEnd(); fc.moveNext())
{
s += fc.item();
s += "<br>";
}
return(s);
}
[VBScript]
下列代碼說明如何獲取 Files 集合,以及如何使用 For Each...Next 語句遍歷該集合:
[VBScript]
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFolderList = s
End Function
Files 集合沒有方法。
Drive 對象 | Drives 集合 | File 對象 | Folder 對象 | Folders 集合