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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access to report file denied...

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
US
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:
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();
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top