Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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"];
share|improve this answer
Thanks Alex, Let me check !! – Jithu Dec 5 '11 at 10:43
That Did the Trick :) – Jithu Dec 5 '11 at 11:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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