使用 C# 编辑 Sharepoint 服务器上的文件 [英] Editing a file on a Sharepoint Server with C#

查看:71
本文介绍了使用 C# 编辑 Sharepoint 服务器上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 C# 在 Sharepoint 上编辑 PowerPoint 文件.我可以直接访问该目录,所以我尝试这样做,就像我在本地系统上编辑 PPT 文件一样:

I am trying to edit a PowerPoint file on a Sharepoint through C#. I have direct access to the directory so I tried doing it like I would if I where to edit a PPT file on my local system:

// Open Presentation
pptPresentation = pptApplication.Presentations.Open(@"\\sharepoint.adress.com@SSL\UserWWWRoot\folder\subfolder\Pres.pptx");

// Open slide on which ID has to be added.
pptSlide = pptPresentation.Slides[slideNumber];

// Add Textbox
shape = pptSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 1, 1);

[...]

但我总是在第一行代码中收到拒绝访问"错误,即使我已登录并在另一个窗口中打开该文件夹也是如此.我是否必须以任何特殊方式打开文件,因为它位于 Sharepoint 上?有没有更好的方法来做到这一点?

But I always get a "Access Denied" error on the first line of code, even if I am logged in and have the folder open in another window. Do I have to open the file in any special way because it's on a Sharepoint? Is there a better approach to doing this?

有效的是将文件复制到我的本地目录,然后打开编辑并将其复制回来.但出于多种原因,我不允许这样做.

What worked was copying the file to my local directory and then opening editing it and copying it back. But I am not allowed to do that for multiple reasons.

推荐答案

您需要登录 Sharepoint.为此,您可以使用 CSOM(客户端 Sharepoint 对象模型)网上有很多文档.

you need to be login to Sharepoint. To do This, you can use CSOM (client Sharepoint object model) There is a lot off documentation on the net.

示例:使用 SharePoint Foundation 2010 托管客户端对象模型使用 Open XML

使用客户端对象模型

这篇关于使用 C# 编辑 Sharepoint 服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆