我打算用Aspose.Words程序集将Word转换成PDF,但问题出现在转换完成后我想删掉PDF,但提示文件已在IIS express worker process中打开,导致我删除不了PDF文件,提示信息如下:
我尝试用代码删除,但在Aspose.Words中好像没有关闭PDF的相关代码,请问我该怎么做才能关掉PDF?
以下是我转换PDF的源代码
protected bool WordToPdf(string sourcePath, string targetPath)
{
try
{
//读取doc文档
Aspose.Words.Document doc = new Aspose.Words.Document(sourcePath);
//转换为PDF文件并保存
doc.Save(targetPath, SaveFormat.Pdf);
return true;
}
catch
{
return false;
}
}