SPDocDiscussionCollection Class
NOTE: This API is now obsolete.
Represents the collection of SPDocDiscussion objects associated with documents in a specific document library.
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.SPBaseCollection
Microsoft.SharePoint.SPDocDiscussionCollection
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Use the GetDocDiscussions method of the SPWeb class to return all the document discussions for a specified folder in a site.
The following code example iterates through the Shared Documents folders of every site in the current site collection and, if the number of comments made in discussions of a document exceeds 10, copies the document into a subfolder within the document library. If the subfolder does not exist, the example creates it.
SPSite oSiteCollection = SPContext.Current.Site; SPWebCollection collWebsites = oSiteCollection.AllWebs; foreach (SPWeb oWebsite in collWebsites) { SPDocDiscussionCollection collDocDiscussions = oWebsite.GetDocDiscussions("Shared Documents"); foreach (SPDocDiscussion oDocDiscussion in collDocDiscussions) { if (oDocDiscussion.CommentCount > 10) { SPFileCollection collFiles = oWebsite.Folders["Shared Documents"].Files; SPFolderCollection collFolders = oWebsite.Folders["Shared Documents"].SubFolders; SPFolder oFolder = oWebsite.GetFolder("Shared Documents/Discussed"); if (!oFolder.Exists) { oFolder = collFolders.Add("Shared Documents/Discussed"); } string strUrl = oDocDiscussion.DocUrl.ToString(); int intIndex = strUrl.LastIndexOf("/"); string strNewUrl = strUrl.Substring(intIndex); collFiles[strUrl].CopyTo(oFolder.Url + strNewUrl); } } oWebsite.Dispose(); }
Note |
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note