PresentationLockingBehavior

PresentationLockingBehavior 枚举

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

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实例的生命周期内被锁定,即不能被其他进程更改或删除。

另见