简体   繁体   English

文件不存在异常-Spire PDF for .NET

[英]File doesn't exist exception - Spire PDF for .NET

I am using the following code to attempt to print a PDF file using Spire PDF. 我正在使用以下代码尝试使用Spire PDF打印PDF文件。

Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();

doc.LoadFromFile(monroneyFilename);

doc.PrinterName = monroneyPrinter;
lock (printLock)
{
    doc.PrintDocument.Print();
}

When it gets to the LoadFromFile method, it gives me a File doesn't exist exception. 当它进入LoadFromFile方法时,它给了我File不存在的异常。 The rest of the code doesn't execute. 其余代码不执行。

The monroneyFilename is "p:\\foldername\\11111111111111111.pdf" where the ones are 17 characters representing a Vehicle Identification Number. monroneyFilename是“ p:\\ foldername \\ 11111111111111111.pdf”,其中17个字符代表车辆识别号。

There are no spaces in the filename or folder name, so the other answers I've seen about this do not apply. 文件名或文件夹名称中没有空格,因此我所见过的其他答案均不适用。

I'm running this from within an ASP.NET Web Service. 我正在ASP.NET Web服务中运行它。

Anyone have any ideas? 有人有想法么?

I was able to discover the problem. 我发现了问题所在。 The P: drive was mapped to a folder on a network PC on a VPN on the server. P:驱动器已映射到服务器上VPN上网络PC上的文件夹。 I was crossing domains, so the user for the AppPool of the web service was not able to access the files on the remote server. 我正在穿越域,因此Web服务的AppPool的用户无法访问远程服务器上的文件。 I was able to copy the PDF locally and access it that way to test and it worked fine. 我能够在本地复制PDF并以这种方式访问​​它进行测试,并且效果很好。

It seems Spire does not give exceptions for bad credentials, it just tells you the file doesn't exist. 看起来Spire不会为凭据错误提供例外,它只是告诉您该文件不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM