PresentationLockingBehavior

PresentationLockingBehavior 枚举

表示在加载和使用 IPresentation 实例时对 IPresentation 源(文件或 Stream)的处理行为。

public enum PresentationLockingBehavior

名称描述
LoadAndRelease0源仅在 IPresentation 构造函数执行期间被锁定。如果 IsTemporaryFilesAllowed 设置为 false,则所有 BLOB 将被加载到内存中。否则,可能会使用其他方式,例如临时文件。此行为比 KeepLocked 慢,如果可以将源的所有权传递给 IPresentation,建议使用 KeepLocked。
KeepLocked1源将在 IPresentation 实例的整个生命周期内被锁定,直至其被释放。IsTemporaryFilesAllowed 必须设置为 true 才能使用此行为,否则将抛出异常。推荐使用此行为,它比 LoadAndRelease 更快且占用更少的内存。

备注

源是传递给 IPresentation 构造函数的参数。以下示例中,源是 “pres.pptx” 文件:

LoadOptions loadOptions = new LoadOptions { 
  BlobManagementOptions = { PresentationLockingBehavior = PresentationLockingBehavior.KeepLocked } };
using (IPresentation pres = new Presentation("pres.pptx", loadOptions)) { }

对于此示例,源(“pres.pptx” 文件)将在 IPresentation 实例的生命周期内被锁定,即其他进程无法更改或删除它。

另请参阅