Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports: saving reports within the webroot

Status
Not open for further replies.

atropozzz

Programmer
Mar 19, 2002
16
AT
hi everybody!

the following error occurs when i try to save a pdf-file generated by crystal reports to my webserver:


-----
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Error in File C:\WINNT\TEMP\temp_6fff5352-f1d6-4664-9b6d-6b7f09c0e563.rpt: Access to report file denied. Another program may be using it
-----

this is the part of my asp.net procedure which should export the report:

-----
exportFileName = "c:\inetpub\rptJournal.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
rptJournal.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
DiskOpts.DiskFileName = exportFileName
rptJournal.ExportOptions.DestinationOptions = DiskOpts
rptJournal.Export()
-----

when i use the exportfilename "c:\report.pdf" or "c:\dir\report.pdf" there is no problem. only if i want to save the report within my webserver directory the exception is thrown.

HEEEEELP!
 
this is what I do in c# where cr is the Crystal Report class of my report:

strName = @"C:\InetPub\ + Session.SessionID.ToString() + ".pdf";
crDestination = new DiskFileDestinationOptions();
crDestination.DiskFileName = strName;
crExportOpt = cr.ExportOptions;
cr.ExportOptions.DestinationOptions = crDestination;
cr.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
cr.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

cr.Export();

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(strName);
Response.Flush();
Response.Close();

System.IO.File.Delete(strName); //after viewing it, the file will be deleted.

hth Daren J. Lahey
Just another computer guy...
 
hi all!

thanks alcar! i already solved the problem on my own. for those who are interested in:

.) export the report to a directory outside the webroot:

-----
exportFileName = "c:\reports\report.pdf"
rptJournal.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
rptJournal.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
DiskOpts.DiskFileName = exportFileName
rptJournal.ExportOptions.DestinationOptions = DiskOpts
rptJournal.Export()
-----

.) move the report to the destination directory within the webroot:

-----
If System.IO.File.Exists("c:\inetpub\ Then
System.IO.File.Delete("c:\inetpub\ End If
System.IO.File.Move("c:\reports\report.pdf", "c:\inetpub\-----

there is also the possibility to configure machine.config as i found in the crystaldecisions group:

....You need to make sure that in your machine.config the <processmModel> tag has the parameter &quot;userName&quot; set to &quot;SYSTEM&quot;, not &quot;MACHINE&quot;. Its actuall that crystal cant write the temporary report files to the app directory....

anyway - this method does not at all care about security issues ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top