SAP Knowledge Base Article - Public

3003155 - ReportDocument.ExportToHttpResponse leaves behind a temp file in C:\Windows\Temp that cannot be deleted - Crystal Reports for Visual Studio


Certain functionality of previewing Crystal Reports across VRL attempts to write temp files to C:\Windows\Temp with a naming scheme of tmpXXXX.tmp where the Xs are four hexadecimal characters limiting the number of files to 65,536. Errors are encountered when the number of tmpXXXX.tmp files reaches 65,535 until these temp files are manually deleted.

Calls to the ReportDocument object's ExportToHttpResponse create the .tmp file. After it is created calling the .Close() and/or the .Dipose() method on the object fails to remove the file in C:\Windows\Temp.

The file is also owned by a process and cannot be removed programmatically afterwards unless we restart the VRLCrystal process entirely.

Calling Response.End() on the response that is sending the report back over the wire does not release the object from the process either.


Crystal Reports for Visual Studio

Reproducing the Issue

Simple test app:

protected void Page_Init(object sender, EventArgs e)

private void ExportToResponse(ReportDocument report)
var exportOptions = new ExportOptions
ExportFormatType = ExportFormatType.PortableDocFormat,
ExportFormatOptions = new PdfFormatOptions
FirstPageNumber = 1,
LastPageNumber = 1,
UsePageRange = true,
CreateBookmarksFromGroupTree = true

report.ExportToHttpResponse(exportOptions, Response, true, Path.GetFileNameWithoutExtension(report.FileName));
catch (Exception e)
throw e;


The cause is noted in this article:


The issue has been escalated to R&D to possibly find a solution in SP 30

In the mean time you can add this to handle the internal exception:

finally{   Response.Flush();   Response.SuppressContent = true;   var httpContext = HttpContext.Current;   httpContext.ApplicationInstance.CompleteRequest();}


CR for VS, ExportToHttpResponse, .NET, TMP , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio