从URL创建SPSite

由一个已知的URL创建一个SPSite

代码实现

              try

            {

                Uri site_uri = new Uri(<CreateSiteUrl>);

              

                //将要创建的网页在当前环境下是否已经存在

                if (SPSite.Exists(site_uri))

                {

                    //Error処理

                }

                //使用下面代码,必须添加using Microsoft.SharePoint.Administration;

                SPWebApplication spApp = SPWebApplication.Lookup(site_uri);

                // 网站集的作成

                //日文环境下使用1041

                SPSite newSPSite = spApp.Sites.Add(

                    <site_url>,

                    < site_name >,

                    string.Empty,

                    1041,

                    < SiteTemplateTitle>,

                    < OwnerLoginName>,

                    string.Empty,

                    < OwnerMailAddress>

                    );

            }

            catch (Exception e)

            {   

                            //ERROR处理

            }

posted on 2009-04-02 16:24  阿米巴原虫  阅读(473)  评论(0编辑  收藏  举报