Reputation: 8636
Hi all I have written a code to retrieve the lists available in SharePoint using console application
My code is as follows
string strSite="http://dorababu:1904/";
SPSite spSite=new SPSite(strSite);
SPWeb spweb=spSite.RootWeb;
foreach(SPList objList in spweb.Lists)
{
console.WriteLine(objList.Title);
}
spweb.Dispose();
spSite.Dispose();
consol.ReadLine();
Can some one help me this is not showing the title
Upvotes: 1
Views: 1236
Reputation: 577
I Would go for using the Client Object Model for this since you're using SharePoint 2010. With this code you can load the SharePoint content from outside the server.
var ctx = new ClientContext("http://tests");
var lists = ctx.Site.RootWeb.Lists;
ctx.Load(lists);
ctx.ExecuteQuery();
foreach (var list in lists)
Console.WriteLine(list.Title);
Console.ReadKey();
You need to add the following references for this to work:
Microsoft.SharePoint.Client
Microsoft.SharePoint.Client.Runtime
Upvotes: 2