SPDocDiscussionCollection Class

NOTE: This API is now obsolete.

Represents the collection of SPDocDiscussion objects associated with documents in a specific document library.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

'Declaration
<ObsoleteAttribute("SPDocDiscussionCollection is deprecated", False)> _
Public Class SPDocDiscussionCollection _
	Inherits SPBaseCollection
'Usage
Dim instance As SPDocDiscussionCollection

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.

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 
NoteNote

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: