fso 怎样取得第一个文件夹名?

来源:百度知道 编辑:UC知道 时间:2024/05/30 06:56:26
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
Response.Write f1.name
Next

上面这是通过遍历的方式得到文件夹名的,我现在想问的是怎样直接获取第一个或者第二个文件夹名呢?类似这样:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
Response.Write fc(0).name

这样的 但是 fc(0).name 写法是错误的 有谁可以纠正下吗 (asp上用的)

是错误的,在ASP里我试过,确实不能这么用的。

fc(参数).name
里面的参数应该是指定的Key,而Key是用VBS在创建文件夹时附与的,但这里没有创建,所以就无法附key。

好似是没有办法吧,只能这样写了:
For Each f1 in fc
a= f1.name
exit for
Next
response.write a

fc(0).name 写法不错啊,只要fc is not nothing