Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

SPWeb.GetListsOfType method

Gets the lists of the specified type.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPListCollection GetListsOfType(
	SPBaseType baseType
)

Parameters

baseType
Type: Microsoft.SharePoint.SPBaseType

The list type.

Return value

Type: Microsoft.SharePoint.SPListCollection
The lists with the specified base list type.

Use this method to query a collection of lists of the specified base list type from the website.

The following example is a console application that gets the document libraries on a website, iterates through the lists, and prints each list title to the console.

using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("http://localhost"))
         {
            using (SPWeb web = site.OpenWeb())
            {
               SPListCollection lists = web.GetListsOfType(SPBaseType.DocumentLibrary);

               foreach (SPList list in lists)
               {
                  Console.WriteLine(list.Title);
               }
            }
         }
         Console.ReadLine();
      }
   }
}
Show:
© 2015 Microsoft