sharepoint foundation服务器端对象模型
sharepoint foundation服务器端对象模型是sharepoint开放给用户的编程接口,对sharepoint的数据访问以及操作都需要通过这些接口来进行访问,所有对sharepoint的定制都需要通过对象模型来操作,需要使用sharepoint2010对象模型的第一步是在解决方案里添加对Microsoft.SharePoint.dll的引用,这个dll通常位于c:\program files\common files\microsoft shared\web server extensions\14\isapi文件夹下面。
在vs 2010里开发sharepoint项目有两点需要注意:第一是项目配置里一定要选择.net3.5作为目标框架,第二是目标平台要选x64兼容。
第一个Hello World
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
const string siteURL = "http://localhost";
using (SPSite site=new SPSite(siteURL))//获取对该站点集对象的引用
{
SPWeb web = site.RootWeb;//获取对跟站点的引用
foreach (SPList list in web.Lists)//遍历根站点下所有列表
{
if (list.Hidden)//如果该列表不是隐藏列表
{
Console.WriteLine(list.Title);
}
}
}
}
}
}

浙公网安备 33010602011771号