Get List Instance from the List GUID

Leave a Comment
Hello folks,

In One of My Project POC, I Came across a situation where I have a List GUID and but I don't know it is belongs to which List in my Site.
I Need to get the List Instance by using the GUID.

The Following Code Snippet will return the List Instance by using the GUID of the List.


public void FindListName()
        {
            try
            {                
                using (SPSite _oSite = new SPSite("http://Server:1234"))
                {
                    using (SPWeb _oWeb = _oSite.OpenWeb())
                    {
                        SPList list1 = _oWeb.Lists[new Guid("B9E83C80-BF31-4800-A02B-                                                                                   6A6070C6BD08")];
                        if (list1 != null)
                        {
                            Console.WriteLine("" + list1.Title);
                        }
                    }
                }
            }
            catch (Exception ex)
            { 
                throw;
            }

        }

Related Post

0 comments:

Post a Comment