Partager via


GetItemsInFolder Method

The GetItemsInFolder method of the SPDocumentLibrary class returns a collection of items from the document library based on the specified view and folder.

Parameters

view   A Microsoft.SharePoint.SPView object representing the view through which to retrieve items from the document library.

folder   A Microsoft.SharePoint.SPFolder object representing the folder from which to retrieve items.

Return Value

A Microsoft.SharePoint.SPListItemCollection object that represents the documents.

Remarks

If the document library contains one or more subfolders and the library itself is passed as the folder parameter, the GetItemsInFolder method returns all items in the top-level folder, including the subfolders themselves, but excluding any items within the subfolders.

Example

The following code example uses the GetItemsInFolder method to return the IDs of all items within the subfolder. The integer IDs are indexed with respect to the overall collection of items contained within the library.

This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security