如何使用 C# 访问共享点数据?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1733514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 20:23:32  来源:igfitidea点击:

How to access sharepoint data using C#?

c#.netsharepointsharepoint-2007moss

提问by Preeti

I am working on project where I have to access SharePoint data in C#.

我正在从事必须在 C# 中访问 SharePoint 数据的项目。

I've never done this before; and have the following questions?

我以前从未这样做过;并有以下问题?

How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?

我将如何从 C# 访问 SharePoint 数据?我使用什么 API?是否有任何教程可以帮助我入门?

采纳答案by Preeti

There two ways in which you can access Sharepoint data:

您可以通过两种方式访问​​ Sharepoint 数据:

  1. By Using Microsoft.Sharepoint.dll In this case you need to do coding on same machine (windows server).

  2. Second way is to use Sharepoint Web Services. This will allow developer to do developement work on different machine.

  1. 通过使用 Microsoft.Sharepoint.dll 在这种情况下,您需要在同一台机器(Windows 服务器)上进行编码。

  2. 第二种方法是使用 Sharepoint Web 服务。这将允许开发人员在不同的机器上进行开发工作。

回答by Traveling Tech Guy

Start at the Sharepoint SDK page. Download the SDK, and look at the sample code on MSDN.

Sharepoint SDK 页面开始。下载SDK,查看MSDN上的示例代码。

Added later: according to MS, thisis a better site for all things related to Sharepoint development.

后来补充:根据 MS 的说法,是一个更好的网站,可以提供与 Sharepoint 开发相关的所有内容。

回答by Shoban

You have to install VS 2005 or VS 2008 extensionsfor sharepoint. Intsllaing them on xp can be tricky and this pageshould hep you with that.

您必须为 sharepoint安装VS 2005 或 VS 2008 扩展。在 xp 上安装它们可能很棘手,这个页面应该可以帮助你。

回答by Amr Badawy

you should also CAML Querywhich you should know to query data from sharepoint lists
you can make use of such a tool http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx

您还应该知道CAML Query从共享点列表中查询数据
您可以使用这样的工具http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx

回答by Preston Guillot

The SDK is a good place to start. The real crux of question lies in whether you are writing code which will live in a SharePoint environment, or writing code which will consume SharePoint data in an external application.

SDK 是一个很好的起点。问题的真正关键在于您是在编写将存在于 SharePoint 环境中的代码,还是编写将在外部应用程序中使用 SharePoint 数据的代码。

In the case of the former, SharePoint has its own API which you gain access to by simply referencing the appropriate DLL.

对于前者,SharePoint 有自己的 API,您只需引用适当的 DLL 即可访问它。

For the latter, SharePoint comes with a set of web services which allow external applications to consume its data. Either these or a set of custom services (running in the SharePoint environment) will be your entry point into SharePoint.

对于后者,SharePoint 附带了一组允许外部应用程序使用其数据的 Web 服务。这些或一组自定义服务(在 SharePoint 环境中运行)将成为您进入 SharePoint 的入口点。

回答by Kasper

To me it sounds like you should use the Out Of The Box SharePoint web services. There is no reason why you should have to learn the entire SharePoint API when you could get along just talking to the web service.

对我来说,听起来您应该使用开箱即用的 SharePoint Web 服务。当您可以与 Web 服务交谈时,您没有理由必须学习整个 SharePoint API。

This primer on InfoQis good, but do a seach on SharePoint Web Services and you will find plenty of sources

InfoQ 上的这本入门读物很好,但是在 SharePoint Web Services 上进行搜索,您会发现大量资源

回答by Mitchell Skurnik

This is how you would do it in PowerShell which is very similar in how you would do it in in C#:

这就是您在 PowerShell 中的执行方式,这与您在 C# 中的执行方式非常相似:

# Lets reference the assembly / GAC that we need for this
function getUsers
{
    param ([string] $verify_sitepath="https://extranet.something.com")
    $verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
        $verify_web=$verify_site.Rootweb
    $verify_web.site.url
    $verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
    foreach($verify_group in $verify_groups)
    {
        foreach($verify_user in $verify_group.users)
        {
            $verify_user = $verify_user -replace "WRKGRP\",""
            Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
        }
    }
}

What this does is gets all the users from SharePoint that are in a text file. Hopefully this gets you at least thinking about how SharePoint is set up.

这样做是从 SharePoint 中获取文本文件中的所有用户。希望这至少能让您思考 SharePoint 的设置方式。

A great resource is the MSDN page with all the functions. They provide a lot of programming samples in C#!

一个很好的资源是具有所有功能的 MSDN 页面。他们提供了大量的 C# 编程示例!