Invalid file name when printing Crystal Report

B

Bernard Goh

Hi All,

I am newbie for ASP.NET programming and I am having this error when I tried
to print a crytal report from my dotnet web application.

Error Message :

Invalid file name.

at .K(String  , EngineExceptionErrorID  ) at .F(Int16 , Int32 ) at
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestCont
ext reqContext) at
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() at
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() at
CrystalWeb.ReportPrinter.Page_Init(Object sender, EventArgs e) in
c:\inetpub\wwwroot\CrystalWeb\ReportPrinter.aspx.vb:line 42

Following is my code for the printing :

Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim Fname As String

crReportDocument = New ReportDocument()


crReportDocument.Load("C:\Inetpub\wwwroot\CrystalWeb\CrystalReport\Report1.r
pt")

Fname = "C:\Inetpub\wwwroot\CrystalWeb\Download\" &
Session.SessionID.ToString & ".pdf"

crDiskFileDestinationOptions = New DiskFileDestinationOptions()

crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With

Try
crReportDocument.Export() ' <-----Error Occured Here

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()

System.IO.File.Delete(Fname)
Catch err As Exception
Response.Write("<BR><BR>")
Response.Write(err.Message.ToString)
Response.Write("<BR><BR>")
Response.Write(err.StackTrace.ToString)
End Try

I exhausted all method that i know of and still don't know what is wrong.
anyone can help me out with this ?

Any help is very much appreciated.

--
Bernard Goh
IT Administrator
Success Electronics & Transformer Manufacturer Sdn Bhd
No.5 & 7,Jalan TSB 8
Taman Industri Sg. Buloh
47000 Sg.Buloh
Selangor Darul Ehsan
 
O

OHM \( One Handed Man \)

You have told it to export to file, but have not given it a file name. I
think you will need to create a stream export it to that, then read that
stream back to the browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top