<p>I've noticed that my temp directory has tons of .rpt files in it -- and it looks like they are the same reports that I'm opening up in the CrystalReportViewer control in my app. Is there any way to stop this or get the viewer to clean them up? I've got CRXI R2 Developer.</p><p><br />TIA,<br />Matt</p>
Which version of Visual Studio are you using? Is your app in ASP.NET or is it a Windows app? Are your app explicitly close the report?
We use the following code in the PageUnload event handler from our ASP.NET app to make sure that the report is closed (C#):
  private void Page_Unload(object sender, EventArgs e)
 {
   CloseReports(crReport);
   crystalReportViewer.Dispose();
   crystalReportViewer = null;
 }
The CloseReports method looks like this:
 private void CloseReports(ReportDocument reportDocument)
 {
   Sections sections = reportDocument.ReportDefinition.Sections;
   foreach (Section section in sections)
   {
     ReportObjects reportObjects = section.ReportObjects;
     foreach (ReportObject reportObject in reportObjects)
     {
       if (reportObject.Kind == ReportObjectKind.SubreportObject)
       {
         SubreportObject subreportObject = (SubreportObject)reportObject;
         ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
         subReportDocument.Close();         Â
       }
     }
   }
   reportDocument.Close();
 }
Â
-Dell
- A computer only does what you told it to, not what you thought you told it to!</p>
Add a comment