title: Get rid of Crystal Report generated files in temp folder - Visual Studio 2008
body: <p>Hi I have pasted below a piece of code where I am displaying a report. I am using Visual Studio 2008 Crystal Report engine. It works all good with the piece of code</p>
  
  <p><strong>Problem:</strong> Everytime a report is being run it generates a ('.*tmp', '.*rpt') files typically in a temp folder <strong>c:\windows\temp</strong> however we can get rid of the *.tmp files by setting a recycle on the application pool but need a way to get rid of the .rpt files.</p>
  
  <p><strong>Found solution:</strong> Call <strong>Close()</strong> and <strong>Dispose()</strong> on the report object. The way I am doing is crReportDoc.Close() then crReportDoc.Dispose()</p>
  
  <p><strong>Actual Problem:</strong> If <strong>Dispose()</strong> is called the report comes up with the following error <strong><em>'Object reference not set to an instance of an object'</em></strong></p>
  
  <p>I will really appreciate if one of the fellow mates can help me with a solution as I am quite new to programming.</p>
  
  <p>Thanks</p>
  
  <pre><code>        Dim crReportDoc = New CrystalDecisions.CrystalReports.Engine.ReportDocument           
          crReportDoc = Session("ReportDocument")
          ReportViewer.DisplayToolbar = True
          ReportViewer.EnableDrillDown = True
          ReportViewer.DisplayGroupTree = False
          ReportViewer.Visible = True
          ReportViewer.DisplayToolbar = True
          ReportViewer.ReportSource = crReportDoc
  </code></pre>