Folder.Items 方法
检索一个 FolderItems 对象,该对象代表文件夹中项的集合。
语法
retVal = Folder.Items()
参数
此方法没有任何参数。
返回值
类型: FolderItems**
对 FolderItems 对象的对象引用。
备注
注意
并非所有方法都是针对所有文件夹实现的。 例如,没有为 控制面板 文件夹 (CSIDL_CONTROLS) 实现 ParseName 方法。 如果尝试调用未实现的方法,则会引发0x800A01BD (十进制 445) 错误。
示例
以下示例使用 Items 来确定 C:\Windows 文件夹中的项目数。 显示 JScript、VBScript 和 Visual Basic 的正确用法。
Jscript:
<script language="JScript">
function fnFolderObjectItemsJ()
{
var objShell = new ActiveXObject("shell.application");
var objFolder = new Object;
objFolder = objShell.NameSpace("C:\\WINDOWS");
if (objFolder != null)
{
var objFolderItems = new Object;
objFolderItems = objFolder.Items();
if (objFolderItems != null)
{
document.write (objFolderItems.Count);
}
}
}
</script>
VBScript:
<script language="VBScript">
function fnFolderObjectItemsVB()
dim objShell
dim objFolder
set objShell = CreateObject("shell.application")
set objFolder = objShell.NameSpace("C:\WINDOWS")
if (not objFolder is nothing) then
dim objFolderItems
set objFolderItems = objFolder.Items
if (not objFolderItems Is Nothing) then
document.write objFolderItems.Count
end if
set objFolderItem = nothing
end if
set objFolder = nothing
set objShell = nothing
end function
</script>
Visual Basic:
Private Sub btnFolderObjectItems_Click()
Dim objShell As Shell
Dim objFolder As Folder
Set objShell = New Shell
Set objFolder = objShell.NameSpace("C:\WINDOWS")
If (Not objFolder Is Nothing) Then
Dim objFolderItems As FolderItems
Set objFolderItems = objFolder.Items()
If (Not objFolderItems Is Nothing) Then
Dim vCount As Variant
vCount = objFolderItems.Count
End If
Set objFolderItems = Nothing
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
要求
要求 | 值 |
---|---|
最低受支持的客户端 |
Windows 2000 专业版、Windows XP [仅限桌面应用] |
最低受支持的服务器 |
Windows 2000 Server [仅限桌面应用] |
标头 |
|
IDL |
|
DLL |
|