Поделиться через


SPFolderCollection Class

The SPFolderCollection class represents a collection of SPFolder objects.

System.Object

   Microsoft.SharePoint.SPBaseCollection

      Microsoft.SharePoint.SPFolderCollection

Public Methods

The following table shows the public methods of the SPFolderCollection class and a brief description of each.

Name Description
Add Adds the folder located at the specified URL to the collection.
Delete Deletes the folder located at the specified URL from the collection.

Public Properties

The following table shows the public properties of the SPFolderCollection class, the data type of each property, and a brief description of each.

Name Data Type Description
Count Int32 Gets the number of folders in the collection.
Folder Microsoft.SharePoint.SPFolder Gets the parent folder of the collection.
Item(Int32) Microsoft.SharePoint.SPFolder Gets the folder object at the specified index in the collection.
Item(String) Microsoft.SharePoint.SPFolder Gets the folder object located at the specified URL from the collection.
Web Microsoft.SharePoint.SPWeb Gets the parent Web site of the collection.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.

Remarks

Use the Folders property of the SPWeb class, or the Subfolders property of the SPFolder class, to return the collection of folders for a site or folder. To create a folder, use the Add method represented in the table above.

Use an indexer to return a single folder from the collection. For example, assuming the collection is assigned to a variable named myFolders, use myFolders[index] in C#, or myFolders(index) in Visual Basic .NET, where index is either the index number of the folder in the collection or the display name of the folder.

Example

The following code example copies all the subfolders of a Shared Documents document library, excluding the Forms subfolder, into another document library on the same site.

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

Requirements

Namespace: Microsoft.SharePoint

Platforms: Microsoft Windows Server 2003

Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)

Security: Code Access Security