首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在C#中创建Sharepoint网站

在C#中创建Sharepoint网站
EN

Stack Overflow用户
提问于 2019-01-27 12:15:02
回答 1查看 64关注 0票数 0

我正在尝试使用Sharepoint客户端命名空间创建一个Sharepoint站点,完整代码如下

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    private void button1_Click(object sender, EventArgs e)
    {

        SPSite topLevelSite = new SPSite("http://localhost");
        SPWeb spWebInstance = topLevelSite.OpenWeb();
        String siteTemplate = spWebInstance.WebTemplate;
        try
        {
            SharePointWebInstance.Webs.Add("the name", "name", "new site added", (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID, siteTemplate, false, false);
        }
        catch (Exception ex)
        {
            //...
        }
        finally
        {
            topLevelSite.Close();
            SharePointWebInstance.Dispose();
        }
    }
}

}

我在SharePointWebInstance.Webs.Add上收到了一个C#错误。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-27 21:56:31

您需要使用自己创建的SPWeb对象,所以它应该是这样的;

代码语言:javascript
复制
spWebInstance.Webs.Add("the name", "name", "new site added", (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID, siteTemplate, false, false);

并且还确保相应地更新SPSite url地址。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54385025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档