0

I want to get reference to document library in code using SP 2013 by url, I am trying the SPWeb.GetList(url); but it works for lists only.

any help?

1 Answer 1

0

Try:

var list = web.Lists["Documents"];
SPDocumentLibrary doclib =   (SPDocumentLibrary)list;
6
  • Hi Max, thanks for your response, I want to be able to get the document library by its URL not by its name, as I will have multi lingual site, so the Documents will not work in all languages, I need a way to make this: SPWeb.GetList("/lists/mylist"), but this method works on lists only. Thanks Commented Jun 16, 2013 at 12:29
  • You have to know the name apparently - by url it somehow does not work. Commented Jun 16, 2013 at 15:57
  • But it's weird there is an API to retrieve it for lists by URL but it doesn't work for libraries? that's strange! Commented Jun 16, 2013 at 16:32
  • You could decompile the function and learn why Commented Jun 16, 2013 at 19:42
  • how can I do that? Commented Jun 17, 2013 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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