Saravana Kumar S

Saravana Kumar S

  • NA
  • 37
  • 13.2k

How to check particular List is Exists or not in SharePoint 2010 ?

Oct 25 2012 9:28 AM
How to check particular List is Exists or not in SharePoint 2010 ?

TryGetList method in SharePoint 2010


below is sample code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Microsoft.SharePoint;
 
namespace MultiChoice
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName/sites/Vijai/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists.TryGetList("Test");
                    if (list != null)
                    {
List is Exists 
                       
                    }
   else
   {
List Is not Exists 

   }
                }
            }
        }
    }
}


Answers (2)