【发布时间】:2020-04-25 12:37:54
【问题描述】:
当我打印文件 A.pdf 和 B.pdf 时,我运行以下代码:
if (File.Exists(@"C:\Users\Luca\Desktop\A.pdf") == true && File.Exists(@"C:\Users\Luca\Desktop\B.pdf") == true)
{
using (PdfDocument one = PdfReader.Open(@"C:\Users\Luca\Desktop\A.pdf", PdfDocumentOpenMode.Import))
using (PdfDocument two = PdfReader.Open(@"C:\Users\Luca\Desktop\B.pdf", PdfDocumentOpenMode.Import))
using (PdfDocument outPdf = new PdfDocument())
{
CopyPages(one, outPdf);
CopyPages(two, outPdf);
outPdf.Save(@"C:\Users\Luca\Desktop\C.pdf");
}
}
但程序显示错误:
"System.IO.IOException: 'The process cannot access the 'C: \ Users \ Luca \ Desktop \ B.pdf' file because it is in use by another process.'.
我尝试使用Task.Delay(500);的方法来留出时间打印,但错误再次出现
【问题讨论】:
-
根据我的测试,我没有遇到你得到的错误。不过,我有两个建议。首先,请检查您的pdf文件是否已被其他应用程序使用。其次,你可以把你的pdf路径放到d盘。
标签: c# visual-studio printing merge