我们正在使用Crystal Report Export to 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);
我们已向temp文件夹中的每个人授予了写权限。并给予服务器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天就会再次出现此问题。任何帮助将不胜感激。
答案 0 :(得分:0)
错误消息显示“文件名无效”。你应该考虑你的道路可能是畸形的。
AppConfig.SitePath
中有什么价值?
尝试使用Path.Combine
,如下所示:
var reportPath = System.IO.Path.Combine(AppConfig.SitePath, "Form201.rpt");
rptDoc.Load(reportPath);
这应确保您的路径正确形成。