Skip to Content
0
May 27, 2016 at 05:43 AM

Export to pdf: The system cannot find the path specified.

1685 Views

Hi,

I am having trouble troubleshooting the cause of my error when attempting to export a pdf report.

Dim filename As String

filename = Request.QueryString("report") & "_" & Request.QueryString("user") & "_" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".pdf"

exportPath = Request.PhysicalApplicationPath & filename

Try

myReport.ExportToDisk(ExportFormatType.PortableDocFormat, exportPath)

Catch ex As Exception

Response.Write("Export Error: <BR>")

Response.Write(exportPath)

Response.Write("<BR>")

Response.Write(ex.Message.ToString())

End Try

This code will fail, with the following displayed:

Export Error:

C:\websites\reporttest\reports\testreportbyparam4_batch_20160527151754.pdf

The system cannot find the path specified.

The directory exists.

I am attempting to call my using a vb.net aspx page with a URL like:

http://localhost/reporttest/reports/OpenReport.aspx?report=testreportbyparam4

where the report name and connection parameters are passed in the the Request scope variables

The report testreportbyparam4.rpt exists in the directory

e.g

Dim reportPath As String

reportPath = Server.MapPath(Request.QueryString("report") & ".rpt")

myReport.Load(reportPath)

I have a virtual directory setup to the reporttest folder under IIS.

If I don't catch the error, my stack trace is as follows:

[COMException (0x80004005): The system cannot find the path specified.

]

CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) +0

CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +1140

CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) +650

CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) +208

CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName) +276

OpenReport.ConfigureCrystalReports() +3158

OpenReport.Page_Init(Object sender, EventArgs e) +7

System.Web.UI.Control.OnInit(EventArgs e) +92

System.Web.UI.Page.OnInit(EventArgs e) +12

System.Web.UI.Control.InitRecursive(Control namingContainer) +134

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +489

I was wondering could it be a permissions problem? I don't really know enough about aspx websites to troubleshoot


I am using Visual Studio 2012, and the the project references the CrystalReportsEngine 13.0.2000.0