Propriété FolderItems.Count
Contient le nombre d’éléments dans la collection.
Cette propriété est en lecture seule.
Syntaxe
iCount = FolderItems.Count
Valeur de la propriété
Entier qui contient une valeur pour la propriété Count.
Exemples
L’exemple suivant utilise Count pour récupérer le nombre d’éléments dans le dossier Windows. Une utilisation correcte est indiquée pour JScript, VBScript et Visual Basic.
Jscript:
<script language="JScript">
function fnFolderItemsCountJ()
{
var objShell = new ActiveXObject("shell.application");
var objFolder;
var ssfWINDOWS = 36;
objFolder = objShell.NameSpace(ssfWINDOWS);
if (objFolder != null)
{
var objFolderItems;
objFolderItems = objFolder.Items();
if (objFolderItems != null)
{
var nCount;
nCount = objFolderItems.Count;
alert(nCount);
}
}
}
</script>
Vbscript:
<script language="VBScript">
function fnFolderItemsCountVB()
dim objShell
set objShell = CreateObject("shell.application")
if (not objShell is nothing) then
dim objFolder
dim ssfWINDOWS
ssfWINDOWS = 36
set objFolder = objShell.NameSpace(ssfWINDOWS)
if (not objFolder is nothing) then
dim objFolderItems
set objFolderItems = objFolder.Items()
if (not objFolderItems is nothing) then
dim nCount
nCount = objFolderItems.Count
alert(nCount)
end if
set objFolderItems = nothing
end if
set objFolder = nothing
end if
set objShell = nothing
end function
</script>
Visual Basic :
Private Sub fnFolderItemsCountVB()
Dim objShell As Shell
Dim objFolder As Folder
Dim ssfWINDOWS As Long
ssfWINDOWS = 36
Set objShell = New Shell
Set objFolder = objShell.NameSpace(ssfWINDOWS)
If (Not objFolder Is Nothing) Then
Dim objFolderItems As FolderItems
Set objFolderItems = objFolder.Items
If (Not objFolderItems Is Nothing) Then
Dim nCount As Integer
nCount = objFolderItems.Count
Debug.Print nCount
End If
Set objFolderItems = Nothing
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Spécifications
Condition requise | Valeur |
---|---|
Client minimal pris en charge |
Windows 2000 Professionnel, Windows XP [applications de bureau uniquement] |
Serveur minimal pris en charge |
Windows 2000 Server [applications de bureau uniquement] |
En-tête |
|
IDL |
|
DLL |
|