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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy