Crystal reports temporary files

Avatar of Andrew Crofts

Basically the report output is being sent by email to a number of customers. I export the output to a pdf and send as an attachment.

I seem to be getting a problem with temporary files building up

In windows\temp I am getting files like

ReceiptEmail .rpt (ReceiptEmail is the form from which the report is run)
~cpe.tmp
~DF8D8D.tmp

Should these temp file get cleaned up or Do I need to do something. Do they build up when the application ends abnormally?


Also it can run so many times and then I get a 'failed to open report' error.

Am I failing to dispose of something properly?

I am doing the same thing in below fashion. I am not creating temp files, i am exporting PDF to specific location and once done i am deleting the file.

rptPDF.Load(HttpContext.Current.Server.MapPath("~/Report/PropertyDetail.rpt")); rptPDF.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptPDF.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; DiskFileDestinationOptions objOptions = new DiskFileDestinationOptions(); objOptions.DiskFileName = HttpContext.Current.Request.PhysicalApplicationPath + "Report\\" + strFileName; rptPDF.ExportOptions.DestinationOptions = objOptions; rptPDF.SetDataSource(dt); rptPDF.Subreports[0].SetDataSource(dt); rptPDF.Subreports[1].SetDataSource(dt); rptPDF.Export(); ///Delete the file if (System.IO.File.Exists(HttpContext.Current.Request.PhysicalApplicationPath + "Report\\" + strFileName))