SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some documents in a document library in SharePoint 2007. The URL is http://abcd:24931/docu/Forms/AllItems.aspx.

I need to display these documents in a data grid view of a Windows form application. I've written:

SPSite siteurl = new SPSite("http://abcd:24931/docu/Forms/AllItems.aspx");

But here (while debugging) the siteurl object does not contain the above complete URL. It only contains http://abcd:24931.

This is my big problem, please provide a solution for my code.

share|improve this question

You cannot take a document library's full url into a new SPSite object, that object can only take in a url to a SiteCollection.

What you can do, is getnan SPList instance of your document library then use the .Site property to get the SPSite object you want.

share|improve this answer

Your Answer


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