0

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

2
  • Why can't you simply get the library by url? Is url different in Turkish? Proposed solution in not effective due to iteration over all lists. – Sergei Sergeev Nov 18 '16 at 7:23
  • @Kai yes url in Turkish site is http://domain/sites/xyz/tr/Sayfalar/Forms/AllItems.aspx while in English it is http://domain/sites/xyz/en/Pages/Forms/AllItems.aspx and it might be different in other languages. I want to be on the safe side. – Ergec Nov 18 '16 at 8:09
1

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")

            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.