I am trying to get the document library from my SharePoint 2010 site.

Let's say, my Document library name is 'Proposals' and Site is 'Http://sok:1234' .

I used the code like,

SPDocumentLibrary doclib = (SPDocumentLibrary)web.Lists["http://sok:1234/Proposals"];

Does it look correct?


No, you should use Id or Display name of your library

using (SPSite site = new SPSite("http://sok:1234"))
    using (SPWeb web = site.OpenWeb())
        SPDocumentLibrary doclib = (SPDocumentLibrary)web.Lists["Proposals"];
  • That Did the Trick :) – Jithu Dec 5 '11 at 11:11

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.