0

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?

1 Answer 1

1

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"];
    }
}
1
  • That Did the Trick :)
    – Jithu
    Dec 5, 2011 at 11:11

Your Answer

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

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