Reputation: 31
We are using Crystal Report Export to PDF function. Below is the code sample
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);
We have given write permission to everyone on temp folder. And given read and execute permission to everyone on C drive of server. Normally it works fine but in week or 10 days suddenly we start getting error .
Load report failed.
Invalid file name.
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) at Testfile.GeneratePDF(Int32 cmpid)
This is the line causing the error
rptDoc.Load(AppConfig.SitePath + "Form201.rpt")
When we reapply read and execute permission for everyone on C drive of the server the issue is resolved.
Please suggest what permission we are missing as this issue reoccurs after every 7 to 10 days. Any help will be appreciated.
Upvotes: 1
Views: 1381
Reputation: 10390
The error message reads "invalid file name." You should consider that your path may be malformed.
What value is in AppConfig.SitePath
?
Try using Path.Combine
, like this:
var reportPath = System.IO.Path.Combine(AppConfig.SitePath, "Form201.rpt");
rptDoc.Load(reportPath);
That should ensure that your path is correctly formed.
Upvotes: 0