Steps
Open Visual Studio in your system.
- Select Console Application template and give as name.
- Add a Microsoft.Client Assembly reference file in right side reference tab in visual studio.
- Replace Program.cs with the source code.
- using System;
- using Microsoft.Office.DocumentManagement.DocumentSets;
- using Microsoft.SharePoint;
- using Microsoft.SharePoint.WebControls;
- namespace ManageDocumentSetTemplate
- {
- class Program
- {
- static void Main(string[] args)
- {
- int count = 0;
- string resultLabel="";
-
-
- SPWeb currentWeb = SPContext.Current.Web;
- SPDocumentLibrary sharedDocuments = (SPDocumentLibrary)currentWeb.Lists["Shared Documents"];
-
-
-
- foreach(SPFolder currentFolder in sharedDocuments.RootFolder.SubFolders)
- {
-
-
- DocumentSet currentDocSet = DocumentSet.GetDocumentSet(currentFolder);
-
-
-
- if (currentDocSet.Item != null)
- {
-
- count += 1;
-
- resultLabel += "Name: " + currentFolder.Name + "<br />";
- resultLabel += "Content Type: " + currentDocSet.ContentType.Name + "<br />";
- resultLabel += "Document Count: " + currentDocSet.Folder.ItemCount + "<br />";
- resultLabel += "Welcome Page: " + currentDocSet.WelcomePageUrl + "<br /><br />";
- }
- }
-
- Console.WriteLine(count.ToString());
- }
- }
- }
Hit F5 and check the output..
Hope you hve enjoyed my articles.