gpt4 book ai didi

c# - 打开 XML SDK : 'The process cannot access the file ' x' because it is being used by another process. '

转载 作者:太空宇宙 更新时间:2023-11-03 22:46:20 27 4
gpt4 key购买 nike

这是我修改 PowerPoint 演示文稿的代码,将其另存为新文件,关闭它,然后尝试打开该文件。

var doc = PresentationDocument.Open(@"d:\temp.pptx", true);    
//... proccess presentation
doc.SaveAs(@"d:\temp2.pptx");
doc.Close();

var doc2 = PresentationDocument.Open(@"d:\temp2.pptx", false);
doc2.Close();

我不明白为什么运行时会抛出异常:

The process cannot access the file 'x' because it is being used by another process.

最佳答案

我注意到 doc.SaveAs() 返回了我刚刚关闭的对象

var savedDoc = doc.SaveAs(@"d:\temp2.pptx") as PresentationDocument;

savedDoc.Close();

关于c# - 打开 XML SDK : 'The process cannot access the file ' x' because it is being used by another process. ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49748968/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com