1

我们正在使用 Crystal Report 导出到 PDF 功能。下面是代码示例

Dim rptDoc As New ReportDocument
rptDoc.Load(AppConfig.SitePath + "Form201.rpt")

ExportOptions rptExportOption;
DiskFileDestinationOptions rptFileDestOption = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions rptFormatOption = new PdfRtfWordFormatOptions();
string reportFileName = filePath;
rptFileDestOption.DiskFileName = reportFileName;
rptExportOption = rptDocument.ExportOptions;
rptExportOption.ExportDestinationType = ExportDestinationType.DiskFile;
rptExportOption.ExportFormatType = ExportFormatType.PortableDocFormat;
rptExportOption.ExportDestinationOptions = rptFileDestOption;
rptExportOption.ExportFormatOptions = rptFormatOption;

rptDocument.Export(rptExportOption);

我们已向临时文件夹中的每个人授予写权限。并授予服务器C盘上的每个人的读取和执行权限。通常它工作正常,但在一周或 10 天内,我们突然开始出错。

加载报告失败。

无效的文件名。

在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() 在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) 在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) 在 Testfile.GeneratePDF(Int32 cmpid)

这是导致错误的行

rptDoc.Load(AppConfig.SitePath + "Form201.rpt")

当我们为服务器 C 盘上的每个人重新申请读取和执行权限时,问题就解决了。

请建议我们缺少什么权限,因为此问题每隔 7 到 10 天就会再次出现。任何帮助将不胜感激。

4

1 回答 1

0

错误消息显示“文件名无效”。您应该考虑到您的路径可能格式不正确。

有什么价值AppConfig.SitePath

尝试使用Path.Combine,像这样:

var reportPath = System.IO.Path.Combine(AppConfig.SitePath, "Form201.rpt");
rptDoc.Load(reportPath);

那应该确保您的路径正确形成。

于 2016-06-07T13:35:57.940 回答