In SharePoint 2013 site. I have many documents library and many folders inside document library.
I'm trying to display all these documents library and folders in console application.
Please suggest something
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using (SPSite oSite = new SPSite("http://pc5"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
//Get the collection of all documents library
SPListCollection docLibraryColl = oWeb.GetListsOfType(SPBaseType.DocumentLibrary);
foreach (SPList list in docLibraryColl)
{
//Display Document libarry name
Console.Write(list.Title);
if (list != null)
{
foreach (SPListItem item in list.Folders)
{
//Display Folder from document library
Console.WriteLine("Folders from" + list.Title+ "are as follows");
Console.WriteLine(item.Title);
}
Console.ReadLine();
}
}
}
}
}
}
}