Error on Previewing PDF report

Can anyOne help me on this error .I am new to crystal I've designed the layout and now wants to preview and export the rpt files in PDF 

Here the code i used.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try
objRptDoc.Load(Server.MapPath("Reports\CrystalReport1.rpt"))
CrystalReportViewer1.ReportSource = objRptDoc
Catch ex As Exception
Throw ex
End Try

Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOption As DiskFileDestinationOptions
Dim fname As String

fname = "c:\exports" & Session.SessionID.ToString & ".pdf"

crExportOptions = objRptDoc.ExportOptions
With crExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crDiskFileDestinationOption = New DiskFileDestinationOptions
crDiskFileDestinationOption.DiskFileName = fname
crExportOptions.DestinationOptions = crDiskFileDestinationOption
Try
objRptDoc.Export()
Catch eExport As ExportException
Response.Write("<br>Print Error : " & eExport.Message)
Catch eX As Exception
Response.Write("<br>Print Error : " & eX.Message)
End Try
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Try
Response.WriteFile(fname)
Catch exp As Exception
Response.Write("<br>Print Error : " & "Write File:" & exp.Message)
End Try
Response.Flush()
Response.Close()
System.IO.File.Delete(fname)
End Sub
When I tried to run tha page the error occured
<br>Print Error : Write File:Could not find file "c:\exportsrf05njqkkr1y3kynmpbodlju.pdf".

I tried to used this code on my project that is connecting to our server and it works just fine .but when i tried creating locally on my machine ..the above error occured. Any help would be appreciated..thanks
1
star21
9/16/2003 10:55:56 AM
asp.net.crystal-reports 7043 articles. 0 followers. Follow

1 Replies
7094 Views

Similar Articles

[PageSpeed] 54

Most problems with exporting to PDF files relate to the ASPNET user account not having permissions to write to that specific folder. Write to the C:\Windows\Temp folder and if that works then that means the other folders need to have their permissions set (by default ASPNET has permission to write to the Temp folder).

HTH,
Brian Bischof
Check out the free CR.NET ebook!
www.CrystalReportsBook.com?cpgn=asp.net
Brian Bischof

www.CrystalReportsBook.com



1
bischofb
9/17/2003 6:34:31 PM
Reply: