UsefulUserName
UsefulUserName

Reputation: 595

Editing a file on a Sharepoint Server with C#

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);

[...]

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.

Upvotes: 0

Views: 1701

Answers (1)

Nico
Nico

Reputation: 456

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.

Exemples : Using the SharePoint Foundation 2010 Managed Client Object Model with the Open XML

Using the Client Object Model

Upvotes: 1

Related Questions