Take the 2-minute tour ×
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.