Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用C#读取外部SharePoint列表?_C#_Search_Sharepoint_External - Fatal编程技术网

如何使用C#读取外部SharePoint列表?

如何使用C#读取外部SharePoint列表?,c#,search,sharepoint,external,C#,Search,Sharepoint,External,我需要能够使用C#搜索或查询外部(在线)SharePoint表。我知道该网站的链接和列表的名称。我的本地计算机上没有SharePoint服务器,因此无法使用本地SharePoint API(因此Visual C#声明),但我可以从该站点读取SharePoint services 如果需要,我会添加更多信息 谢谢。以下是使用SharePoint CSOM 2010的内容 using Microsoft.SharePoint.Client; using Microsoft.SharePoint;

我需要能够使用C#搜索或查询外部(在线)SharePoint表。我知道该网站的链接和列表的名称。我的本地计算机上没有SharePoint服务器,因此无法使用本地SharePoint API(因此Visual C#声明),但我可以从该站点读取SharePoint services

如果需要,我会添加更多信息


谢谢。

以下是使用SharePoint CSOM 2010的内容

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
我就是这样做的,但它可能无法100%准确地解决您的问题

首先,您显然必须连接到SharePoint网站。我建议用它来做开胃菜

我用这个简单的片段来连接:

MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper(site, user, password);
ClientContext context = new ClientContext(site);
context.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
然后,您只需按名称获取列表,最简单的方法是使用如下方法:

public Microsoft.SharePoint.Client.List getList(string name)
{
    context.Load(context.Web.Lists);
    Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(name);
    context.Load(list);
    context.ExecuteQuery();

    return list;
}