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);
                    }
                }
            }
        }
    }
}

posted @ 2012-09-13 11:51  joesphos  阅读(257)  评论(0)    收藏  举报

如果您认为这篇文章还不错或者有所收获,您可以打赏点哦,多多少少没关系,一分一毫也是对我的支持和鼓励。谢谢您!