Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing sharepoint data with Object Model

Status
Not open for further replies.

AT76

Technical User
Apr 14, 2005
460
US
Hi,

I just started working with Sharepoint and was trying to access lists in a specified site. I got the following example off of the web but I'm getting an error. It seems I'm missing a reference to SPSite.

Here's the code:
Code:
using System; 
using Microsoft.SharePoint; 






namespace SPLst 
{ 
	class Class1 
	{ 
		[STAThread] 
		static void Main(string[] args) 
		{ 
			SPSite siteCollection = new SPSite("[URL unfurl="true"]http://spsdev/sites/andrest/default.aspx");[/URL] 
				SPWebCollection sites = siteCollection.AllWebs; 


			foreach (SPWeb site in sites) 
			{ 
				SPListCollection lists =  site.Lists; 


				Console.WriteLine("Site: " + site.Name + "  Lists: " + 
					lists.Count.ToString()); 
			} 


			Console.WriteLine("Press ENTER to continue"); 
			Console.ReadLine(); 
		} 
	} 
}

Any suggestions as to why is not working? Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top