我正在尝试使用Sharepoint客户端命名空间创建一个Sharepoint站点,完整代码如下
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#错误。有什么想法吗?
发布于 2019-01-27 21:56:31
您需要使用自己创建的SPWeb对象,所以它应该是这样的;
spWebInstance.Webs.Add("the name", "name", "new site added", (UInt32)System.Globalization.CultureInfo.CurrentCulture.LCID, siteTemplate, false, false);并且还确保相应地更新SPSite url地址。
https://stackoverflow.com/questions/54385025
复制相似问题