0

I want to fetch the document library object by passing the internalname of the doc lib. is it possible? like

 splist mydoclib = ospweb.lists.trygetlist("INTERNALNAME_OF_DOCLIB");

usually we pass the title/display name of the doc lib / list to fetch the object, but in my case there is a chance that, my customer my change the display name by modifying the doc lib title in future. i would like to avoid this in my code, such that i dont hardcode the doc lib name [display name] in my C# code. am using SSOM

1

The only way that I've figures for how to do this is to read all SPLists into an enumerable, then use a little LINQ magic to get the list you want based on InternalName using the SPList RootFolder.Name property. I have not tested the impact of reading all web lists into memory may have, but a basic example is below....

List<SPList> lists = oWeb.Lists.Cast<SPList>().ToList();
SPList oList = lists.First(o => o.RootFolder.Name == "YourListInternalName");
|improve this answer|||||
  • I will test this and revert here. Thanks for your time. – dasarp Apr 19 '17 at 8:24

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.