I need my website clients to be able to download a report. The report is created at run-time based on options the user selects, and displayed using a Crystal Reports viewer (duh!). I have a button that says "Download in PDF", which is supposed to export the report in PDF format to a temporary location on the server, upload it to the user, and then delete it.
The code that exports the report in PDF format to a temporary folder is the following:
When the code above runs, I get an error that says: "Access to report file denied. Another program may be using it."
I thought it was that ASP.NET didn't have the rights to create files, but (using IIS), I allowed all rights possible, (read, write, run scripts, etc) to all the files and folders in my web site, and I still get the same problem. Also, I changed the path where the temporary PDF is stored (see the line in bold in the code above), and I made it "C:\\MyReport" and, guess what! it works. Of course, I don't think is terribly exiting to save a temporary report to the C drive of my server so I came to you guys so you could help me save it to the \TempFldr instead.
Can anybody tell me what the source of my problem may be?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin
The code that exports the report in PDF format to a temporary folder is the following:
Code:
[COLOR=green]// This is C# code...
// rpt is the report I created[/color]
rpt.ExportOptions.ExportFormatType =
ExportFormatType.PortableDocFormat;
rpt.ExportOptions.ExportDestinationType =
ExportDestinationType.Diskfile;
DiskFileDestinationOptions dskOpt = [COLOR=blue]new[/color]
DiskFileDestinationOptions();
[COLOR=green]// TempFldr is a directory in my web site[/color]
[b]dskOpt.DiskFileName =
[COLOR=blue]this[/color].MapPath("TempFldr\\MyReport.pdf");[/b]
rpt.ExportOptions.DestinationOptions =
dskOpt;
rpt.Export();
I thought it was that ASP.NET didn't have the rights to create files, but (using IIS), I allowed all rights possible, (read, write, run scripts, etc) to all the files and folders in my web site, and I still get the same problem. Also, I changed the path where the temporary PDF is stored (see the line in bold in the code above), and I made it "C:\\MyReport" and, guess what! it works. Of course, I don't think is terribly exiting to save a temporary report to the C drive of my server so I came to you guys so you could help me save it to the \TempFldr instead.
Can anybody tell me what the source of my problem may be?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin