【发布时间】:2019-08-28 09:32:34
【问题描述】:
我有一个 SharePoint 2007 场,我需要使用 C# 连接到它,以便以编程方式获取其数据。
所有这些的目的是获取其所有列表(包括字段和数据)和子网站,以便在 SharePoint Online 中重新创建它们。我成功连接到 SPO,但无法连接到 SharePoint 2007。
using (SPSite site = new SPSite(root_url + "/" + relative_site_url))
{
using (SPWeb web = site.OpenWeb())
{
//SPFolder myLibrary = web.Folders["testdocuments"];
SPWebCollection SitesList = web.Site.AllWebs;
int i = 0;
foreach (string WebSiteName in SitesList.Names)
{
if (WebSiteName.Contains(relative_site_url))
{
//Console.WriteLine("Title: " + WebSite.Title);
//Console.WriteLine("Description: " + WebSite.Description);
Console.WriteLine(i.ToString() + " " + WebSiteName);
Console.WriteLine("Lists:");
GetSiteLists(root_url + "/" + relative_site_url);
i++;
}
}
}
}
}
我期待连接成功。但是,我在尝试连接到本地 SharePoint 2007 时收到此错误消息:
Unhandled Exception: System.IO.FileNotFoundException: The Web application at http://localhost/ could not be
found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administ
rator may need to add a new request URL mapping to the intended application.
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at ExportSolution.Program.GetSiteLists(String root_url, String relative_site_url) in D:\Users\admin\source\repos\
ExportSolution\ExportSolution\Program.cs:line 33
at ExportSolution.Program.Main(String[] args) in D:\Users\admin\source\repos\ExportSolution\ExportSolution\Progra
m.cs:line 17
【问题讨论】:
-
您的 Sharepoint 应用程序托管在哪里?在 80 端口?看来您正在连接到端口 80
标签: c# sharepoint sharepoint-2007