简体   繁体   中英

How do I open an already openeded presentation with PresentationDocument.Open() for PowerPoint Add in?

I have a PowerPoint Add in that create, modify and save presentations. Specific options for the opened presentation should be stored in this presentation file (.pptx) using Open XML, when i try to do this I get an IOException:

**System.IO.IOException : The process cannot access the file 'test.pptx' because it is being used by another process.**

This is a snippet from the code:

**

using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))
{
// add options to pptx file.
}

**

Thank you.

If you need just to read opened presentation using Open XML you can do it this way:

using (Stream stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (PresentationDocument pptPackage = PresentationDocument.Open(stream, false))
{
    // read pptx file.
}

But you can't change presentation this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM