Question

Using C# in Sharepoint 2013 I can reach Pages folder using web.Folders["Pages"] or web.GetFolder("Pages")

Some of our SPWebs are in Turkish language. Whole interface is in Turkish including all default folders.

Problem is Pages becomes Sayfalar in Turkish. Other folder names also different but their internal names are in English so it's not a big deal but Pages internal name is also in Turkish Sayfalar.

This could be a problem in other languages too. Pages may become something else.

So is there a way to get default Pages folder programmatically in any language without using if..then..else

Was it helpful?

Solution

Try the below code:

using (SPSite site = new SPSite(http://url))
{
    using (SPWeb web = site.OpenWeb())
    {
        foreach (SPList list in web.Lists)
        {
            if (list.BaseType == SPBaseType.DocumentLibrary)
            {

                SPDocumentLibrary docLibrary = (SPDocumentLibrary)list;
                if (docLibrary.BaseTemplate == (SPListTemplateType)850)

                    Console.WriteLine("Pages Library")

            }
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top