我正在尝试使用我的HTA文件中的JavaScript和Windows“ActiveXObject('Scripting.FileSystemObject')
获取文件夹内的子文件夹名称:
var fso = new ActiveXObject('Scripting.FileSystemObject');
var subfolders = fso.GetFolder('D:\path\to\myfolder\').SubFolders;
for(var i = 0; i < subfolders.length; i++) {
alert(subfolders[i].Name);
}
OR
var fso = new ActiveXObject('Scripting.FileSystemObject');
for(var subfolder in fso.GetFolder('D:\path\to\myfolder\').SubFolders) {
alert(subfolder.Name);
}
但在这两种情况下我什么都没得到。怎么了?
答案 0 :(得分:1)
好的,我找到了这个解决方案:
var fso = new ActiveXObject('Scripting.FileSystemObject');
var e = new Enumerator(fso.GetFolder('D:\path\to\myfolder\').SubFolders);
for(;!e.atEnd();e.moveNext()) {
alert(e.item().Name);
}