NOTE: This API is now obsolete.
Represents the collection of SPDocDiscussion objects associated with documents in a specific document library.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
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.
Dim siteCollection As SPSite = SPContext.Current.Site Dim sites As SPWebCollection = siteCollection.AllWebs Dim site As SPWeb For Each site In sites Dim discs As SPDocDiscussionCollection = site.GetDocDiscussions("Shared Documents") Dim disc As SPDocDiscussion For Each disc In discs If disc.CommentCount > 10 Then Dim files As SPFileCollection = site.Folders("Shared Documents").Files Dim subFolders As SPFolderCollection = site.Folders("Shared Documents").SubFolders Dim subFolder As SPFolder = site.GetFolder("Shared Documents/Discussed") If Not subFolder.Exists Then subFolder = subFolders.Add ("Shared Documents/Discussed") End If Dim urlString As String = disc.DocUrl.ToString() Dim index As Integer = urlString.LastIndexOf("/") Dim newUrl As String = urlString.Substring(index) files(urlString).CopyTo(subFolder.Url + newUrl) End If Next disc Next site
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.